In python I want to calculate the number of bits required to represent an unsigned number. For eg:
2 --> 2 bits
3 --> 2 bits
10 --> 4 bits
I am simply calculating it as follows len( bin( n ) ) - 2
Is there any other better way to calculate this ? purely using bit manipulation so that I can use it on other languages as well ?