title: How to get the bit size of an int
body: <p>Of course I know a method to do this:</p>
  
  <pre class="lang-cs prettyprint-override"><code>/// &lt;summary&gt;Gets the number of bits needed to represent the number.&lt;/summary&gt;
  public static int Size(int bits)
  {
      var size = 0;
      while(bits != 0)
      {
          bits &gt;&gt;= 1;
          size++;
      }
      return size;
  }
  </code></pre>
  
  <p>So the Size(15) returns 4, and Size(16) returns 5.</p>
  
  <p>But I guess (hope) there is a quicker way. But I couldn't think of (or Google) a nice and smooth (and fast) algorithm.</p>