title: packing bits into an integer in C++
body: <p>I want to pack the lowest two bytes of an integer into another in integer, an stuck at this</p>
  
  <pre><code>for ( int i = 0; i &lt; 8 ; i ++){
           if ((bitmask &amp; ( 1 &lt;&lt; i)))
               result |= 1 &gt;&gt; i;
       }
  </code></pre>