title: C: Unpacking a byte
body: <p>I asked the question <a href="https://stackoverflow.com/questions/2393914/c-building-a-byte">here</a> and now i would like to reverse this procedure</p>
  
  <p>I have an unsigned short that represents a bit pattern, I would like an array of bool[16] that has true or false set for the corresponding bit in the unsigned short.</p>
  
  <p>so far i have</p>
  
  <p>where binary 2 is an unsigned short, that has the bit pattern i wish to unpack.</p>
  
  <pre><code>unsigned short i;
  i = 1&lt;&lt;(sizeof(unsigned short) * 8 - 1);
  
  while (i &gt; 0) {
      if (binary2 &amp; i)
          printf("1");
      else
          printf("0");
      i &gt;&gt;= 1;
  }
  </code></pre>
  
  <p>but i seem to be missing the first bit in my pattern and shifting the remaining ones.</p>