title: How to get the bit length of an integer in C++?
body: <p><strong>The linked question in the close notice is different from this one. See comment by Daniel S. below.</strong></p>
  <p>--</p>
  <p>Let's say there is a variable <code>int x;</code>. Its size is 4 bytes, i.e. 32 bits.</p>
  <p>Then I assign a value to this variable, <code>x = 4567</code> (in binary 10001 11010111), so in memory it looks like this:</p>
  <p>00000000 00000000 000<strong>10001 11010111</strong></p>
  <p>Is there a way to get the length of the bits which matter. In my example, the length of bits is 13 (I marked them with bold).
  If I use <code>sizeof(x)</code> it returns 4, i.e. 4 bytes, which is the size of the whole <code>int</code>. How do I get the minimum number of bits required to represent the integer without the leading <code>0</code>s?</p>