title: Extract n most significant non-zero bits from int in C++ without loops
body: <p>I want to extract the n most significant bits from an integer in C++ and convert those n bits to an integer.</p>
  
  <p>For example</p>
  
  <pre><code>int a=1200;
  // its binary representation within 32 bit word-size is
  // 00000000000000000000010010110000
  </code></pre>
  
  <p>Now I want to extract the 4 most significant digits from that representation, i.e. 1111</p>
  
  <pre><code>00000000000000000000010010110000
                       ^^^^
  </code></pre>
  
  <p>and convert them again to an integer (1001 in decimal = 9).</p>
  
  <p>How is possible with a simple c++ function without loops?</p>