title: Bitwise concatenation in C
body: <p>I'm trying to concatenate two binary numbers in C. So if I have <code>1010</code> and <code>0011</code> I want my result to be <code>10100011</code>. I wrote a short routine that I thought would do the job:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
      int first = 1010;
      int second = 0011;
      int result = (first &lt;&lt; 4) | second;
      printf("%d", result);
      return 0;
  }
  </code></pre>
  
  <p>I understand that the printed number of course is going to be in decimal, but I figured that after my bitwise operations I'd be getting the decimal equivalent of <code>10100011</code>, or 163. However, my result is printed as 16169. So I guess my question is...what part of this am I not understanding here? Is it just a misunderstanding of how printf is working, or are my bitwise operations incorrect? Is it a problem to try to do this with <code>int</code>s?</p>