PyDocs

Nav

Python Runtime Services

int.bit_length

builtins

method of int · Added in 3.1
  • int.bit_length()
Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
1 Example
>>> n = -37
>>> bin(n)
'-0b100101'
>>> n.bit_length()
6
from the Python docs
See Also
No see-alsos for builtins/int.bit_length
0 Notes
No notes for int.bit_length