title: Shifting bit values in C
body: <p>Say I have the following code:</p>
  
  <pre><code>uint32_t fillThisNum(int16_t a, int16_t b, int16_t c){
  
        uint32_t x = 0;
        uint16_t temp_a = 0, temp_b = 0, temp_c = 0; 
  
        temp_a = a &lt;&lt; 24;
        temp_b = b &lt;&lt; 4;
        temp_c = c &lt;&lt; 4;
  
        x = temp_a|temp_b|temp_c;
  
        return x;
  }
  </code></pre>
  
  <p>Essentially what I'm trying to do is fill the 32-bit number with bit information that I can extract at a later time to perform different operations.</p>
  
  <p>Parameter <code>a</code> would hold the first 24 bits of "data", <code>b</code> would hold the next 4 bits of "data" and <code>c</code> would hold the final 4 bits of "data".</p>
  
  <p>I have a couple questions:</p>
  
  <ol>
  <li>Do the parameters have to be the same bit length as the function type, and must they be unsigned?</li>
  <li>Can I assign an unsigned int to a signed int? (i.e. <code>uint32_t a = int32_t b;</code>)</li>
  <li>Can I fill a 32-bit number with the 16-bit parameters so long they don't exceed the length of the 32-bit return value.</li>
  </ol>
  
  <p>Any advice/tips/hints would be much appreciated, thank you.</p>