title: bit-shift operation in accelerometer code
body: <p>I'm programming my Arduino micro controller and I found some code for accepting accelerometer sensor data for later use. I can understand all but the following code. I'd like to have some intuition as to what is happening but after all my searching and reading I can't wrap my head around what is going on and truly understand.</p>
  
  <p>I have taken a class in C++ and we did very little with bitwise operations or bit shifting or whatever you'd like to call it. Let me try to explain what I think I understand and you can correct me where it is needed.</p>
  
  <p>So:  </p>
  
  <ol>
  <li>I think we are storing a value in x, pretty sure in fact.</li>
  <li>It appears that the data in array "buff", slot number 1, is being set to the datatype of integer.</li>
  <li>The value in slot 1 is being bit shifted 8 places to the left.(does this point to buff slot 0?) </li>
  </ol>
  
  <p>This new value is being compared to the data in buff slot 0 and if either bits are true then the bit in the data stored in x will also be true so, 0 and 1 = 1, 0 and 0 = 0 and 1 and 0 = 1 in the end stored value.</p>
  
  <p>The code does this for all three axis: x, y, z but I'm not sure why...I need help. I want full understanding before I progress.</p>
  
  <pre><code>//each axis reading comes in 10 bit resolution, ie 2 bytes.  
  // Least Significant Byte first!!
  //thus we are converting both bytes in to one int
  x = (((int)buff[1]) &lt;&lt; 8) | buff[0];   
  y = (((int)buff[3]) &lt;&lt; 8) | buff[2];
  z = (((int)buff[5]) &lt;&lt; 8) | buff[4];
  </code></pre>