Let's say there is a variable int x. It size is 4 bytes, that is 32 bits.
Then I assign a value to this var, x = 4567 (in binary 10001 11010111); So now, in memory it should look like this:
00000000 00000000 00010001 11010111
Is there a way to get the length of the bits which matter. In my excample, length of bits would be 13 (I marked them with bold). If I use sizeof (x) it returns me 4 bytes, which the size of int. How do I get only the size of bits that represent the number (without the unnecessarily zero's that follow after)?