title: Finding how many bits it takes to represent a 2's complement using only bitwise functions
body: <p>We can assume an int is 32 bits in 2's compliment
  The only Legal operators are: ! ~ &amp; ^ | + &lt;&lt; >></p>
  
  <p>At this point i am using brute force</p>
  
  <pre><code>int a=0x01;
  x=(x+1)&gt;&gt;1; //(have tried with just x instead of x+1 as well)
  a = a+(!(!x));
  </code></pre>
  
  <p>...
  with the last 2 statements repeated 32 times. This adds 1 to a everytime x is shifted one place and != 0 for all 32 bits</p>
  
  <p>Using the test compiler it says my method fails on test case 0x7FFFFFFF (a 0 followed by 31 1's) and says this number requires 32 bits to represent. I dont see why this isnt 31 (which my method computes) Can anyone explain why? And what i need to change to account for this?</p>