int_bytes_intbig.py 385 B

1234567891011121314
  1. print((2**64).to_bytes(9, "little"))
  2. print((2**64).to_bytes(9, "big"))
  3. b = bytes(range(20))
  4. il = int.from_bytes(b, "little")
  5. ib = int.from_bytes(b, "big")
  6. print(il)
  7. print(ib)
  8. print(il.to_bytes(20, "little"))
  9. print(ib.to_bytes(20, "big"))
  10. # check that extra zero bytes don't change the internal int value
  11. print(int.from_bytes(b + bytes(10), "little") == int.from_bytes(b, "little"))