2017-03-03 21:13:27 +00:00
|
|
|
print((2**64).to_bytes(9, "little"))
|
2017-06-15 04:56:21 +01:00
|
|
|
print((2**64).to_bytes(9, "big"))
|
2017-03-03 21:13:27 +00:00
|
|
|
|
2017-01-21 17:15:31 +00:00
|
|
|
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"))
|
2017-06-15 04:56:21 +01:00
|
|
|
print(ib.to_bytes(20, "big"))
|
2017-04-25 03:07:02 +01:00
|
|
|
|
|
|
|
# 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"))
|