title: Concatenate binary representation of two ints
body: <p>Let's say we have two int variables, <code>A</code> and <code>B</code> of bit length <code>N &lt; 16</code> and <code>M &lt; 16</code> respectively.
  We want to have a new int variable <code>C</code> such that the <code>N</code> lowest bits contain the bits of <code>A</code> and the next <code>M</code> bits contain the bits of <code>B</code>. (Assuming all variables are 32 bits long and little endian).</p>
  
  <p>In my solution I slightly cheated by using binary strings instead:</p>
  
  <pre><code>int a = 65535;
  int b = 65;
  String cStr = Integer.toBinaryString(b) + Integer.toBinaryString(a);
  int c = Integer.parseInt(cStr, 2);
  </code></pre>
  
  <p>But, how do I do it using bitwise operators?</p>
  
  <p>Examples: </p>
  
  <p><code>A=1, B=1 (N=1, M=1 resp.) then C = 11
   A = 11000011010100, B = 101100 (N=14, M=6 resp.) then C = 10110011000011010100</code></p>