title: How to extract 2 bytes from a word, and how to make a word from 2 bytes (in C)?
body: <p>I am trying to extract two bytes from a 16-bit word, and to make a 16-bit word from two bytes. This is what I have tried (<em>byte = unsigned char, word = unsigned short</em>):</p>
  
  <p><strong>Split grpix word into 2 bytes:</strong></p>
  
  <pre><code>word grpix; // Assume that the value has been initialized
  
  byte grpixl = grpix &amp; 0x00FF;
  byte grpixh = grpix &amp; 0xFF00;
  </code></pre>
  
  <p><strong>Make grpix word from 2 bytes</strong></p>
  
  <pre><code>byte grpixh; // Assume that the value has been initialized
  byte grpixl; // Assume that the value has been initialized
  
  word grpix = grpixh;
  grpix &lt;&lt;= 8;
  grpix += grpixl;
  </code></pre>
  
  <p>For some reason, my code doesn't work as expected, and now I'm not sure if the "splitting" of the word is wrong, if the "making" of the word is wrong, or both... Could you give me some advice?</p>