circuitpython/tests/basics/bit_length.py
Jeff Epler 20c2dd0c08 core: add int.bit_length() when MICROPY_CYPTHON_COMPAT is enabled
This method of integer objects is needed for a port of python3's
decimal.py module.

MICROPY_CPYTHON_COMPAT is enabled by CIRCUITPY_FULL_BUILD.
2020-09-06 09:53:16 -05:00

5 lines
183 B
Python

for i in range(129):
j = (1 << i)
print(i, (j-1).bit_length(), (j).bit_length(), (j+1).bit_length())
print(i, (-j-1).bit_length(), (-j).bit_length(), (-j+1).bit_length())