blob: 93c00bba103ac54e26e45c5b372350ac0b083636 [file] [log] [blame]
Paul Sokolovskya985b452014-04-09 00:40:58 +03001print((10).to_bytes(1, "little"))
2print((111111).to_bytes(4, "little"))
3print((100).to_bytes(10, "little"))
Paul Sokolovskya985b452014-04-09 00:40:58 +03004print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little"))
5print(int.from_bytes(b"\x01\0\0\0\0\0\0\0", "little"))
6print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little"))
Damien George810133d2017-04-25 12:07:02 +10007
8# check that extra zero bytes don't change the internal int value
9print(int.from_bytes(bytes(20), "little") == 0)
10print(int.from_bytes(b"\x01" + bytes(20), "little") == 1)