circuitpython/tests/basics/int_bytes_intbig.py
Dan Halbert ef61b5ecb5 Initial merge of micropython v1.9.2 into circuitpython 2.0.0 (in development) master.
cpx build compiles and loads and works in repl; test suite not run yet
esp8266 not tested yet
2017-08-25 22:17:07 -04:00

18 lines
421 B
Python

import skip_if
skip_if.no_bigint()
print((2**64).to_bytes(9, "little"))
print((2**64).to_bytes(9, "big"))
b = bytes(range(20))
il = int.from_bytes(b, "little")
ib = int.from_bytes(b, "big")
print(il)
print(ib)
print(il.to_bytes(20, "little"))
print(ib.to_bytes(20, "big"))
# check that extra zero bytes don't change the internal int value
print(int.from_bytes(b + bytes(10), "little") == int.from_bytes(b, "little"))