title: How to return middle bits?
body: <p>I searched online and the common solution for returning <code>x</code> bits from <code>start</code> seems to be: </p>
  
  <pre><code>mask = ((1 &lt;&lt; x) - 1 ) &lt;&lt; start
  </code></pre>
  
  <p>then, <code>mask &amp; value</code>.</p>
  
  <p>However, I'm confused on how this works still. </p>
  
  <p>If I have a number <code>0101 1100</code> and I want to return the two bits from positions 5 and 6 (<code>11</code>)</p>
  
  <pre><code>mask = ((1&lt;&lt;2)-1) &lt;&lt; 5
  </code></pre>
  
  <p><code>1&lt;&lt;2 = 0000 0100</code>, and subtracting 1 yields <code>0000 0011</code> then, shifting 5 is <code>0110 0000</code></p>
  
  <p>If I take <code>0110 0000 &amp; 0101 1100</code> (the original), I get <code>0100 0000</code></p>
  
  <p>This is not the answer I want, so what am I doing wrong? </p>