Bit hack: Expanding bits : <p>I am trying to convert a <code>uint16_t</code> input to a <code>uint32_t</code> bit mask. One bit in the input toggles two bits in the output bit mask. Here is an example converting a 4-bit input to an 8-bit bit mask:</p>

<pre><code>Input    Output
ABCDb -&gt; AABB CCDDb

A,B,C,D are individual bits

Example outputs:

0000b -&gt; 0000 0000b
0001b -&gt; 0000 0011b
0010b -&gt; 0000 1100b
0011b -&gt; 0000 1111b
....
1100b -&gt; 1111 0000b
1101b -&gt; 1111 0011b
1110b -&gt; 1111 1100b
1111b -&gt; 1111 1111b
</code></pre>

<p>Is there a bithack-y way to achieve this behavior?</p>
