title: Make a Integer from 6 bytes or more using C++
body: <p>I am new in <code>C++</code> programming. I am trying to implement a code through which I can make a single integer value from <code>6</code> or more <code>individual bytes</code>.</p>
  
  <p>I have Implemented same for <code>4 bytes</code> and it's working</p>
  
  <p><strong>My Code for 4 bytes:</strong></p>
  
  <pre><code>char *command = "\x42\xa0\x82\xa1\x21\x22";
  __int64 value;
  value = (__int64)(((unsigned char)command[2] &lt;&lt; 24) + ((unsigned char)command[3] &lt;&lt; 16) + ((unsigned char)command[4] &lt;&lt; 8) + (unsigned char)command[5]);
  printf("%x  %x  %x  %x  %x",command[2], command[3], command[4], command[5], value);
  </code></pre>
  
  <p>Using this Code the value of <code>value</code> is <code>82a12122</code> but when I try to do for 6 byte then the result was is wrong.</p>
  
  <p><strong>Code for 6 Bytes:</strong></p>
  
  <pre><code>char *command = "\x42\xa0\x82\xa1\x21\x22";
  __int64 value;
  value = (__int64)(((unsigned char)command[0] &lt;&lt; 40) + ((unsigned char)command[1] &lt;&lt; 32) + ((unsigned char)command[2] &lt;&lt; 24) + ((unsigned char)command[3] &lt;&lt; 16) + ((unsigned char)command[4] &lt;&lt; 8) + (unsigned char)command[5]);
  printf("%x  %x  %x  %x  %x  %x  %x", command[0], command[1], command[2], command[3], command[4], command[5], value);
  </code></pre>
  
  <p>The output value of <code>value</code> is <code>82a163c2</code> which is wrong, I need <code>42a082a12122</code>.
  So can anyone tell me how to get the expected output and what is wrong with the <code>6 Byte</code> Code. </p>
  
  <p>Thanks in Advance.</p>