Can someone explain how this bitMask code works?
<p>This is code that my partner came up with but for some reason I can't get a hold of him to ask him how it's suppose to work. I've been through it many times now and can't seem to get the answer I'm suppose to get.</p>

<pre><code>/**
 * bitMask - Generate a mask consisting of all 1's 
 *   lowbit and highbit
 *   Examples: bitMask(5,3) = 0x38
 *   Assume 0 &lt;= lowbit &lt;= 31, and 0 &lt;= highbit &lt;= 31
 *   If lowbit &gt; highbit, then mask should be all 0's
 *   Legal ops: ! ~ &amp; ^ | + &lt;&lt; &gt;&gt;
 */
int bitMask(int highbit, int lowbit) {
   int i = ~0;
   return ~(i &lt;&lt; highbit &lt;&lt; 1) &amp; (i &lt;&lt; lowbit);
}
</code></pre>