Paul Sokolovsky | a985b45 | 2014-04-09 00:40:58 +0300 | [diff] [blame] | 1 | print((10).to_bytes(1, "little")) |
| 2 | print((111111).to_bytes(4, "little")) |
| 3 | print((100).to_bytes(10, "little")) |
Paul Sokolovsky | a985b45 | 2014-04-09 00:40:58 +0300 | [diff] [blame] | 4 | print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little")) |
| 5 | print(int.from_bytes(b"\x01\0\0\0\0\0\0\0", "little")) |
| 6 | print(int.from_bytes(b"\x00\x01\0\0\0\0\0\0", "little")) |
Damien George | 810133d | 2017-04-25 12:07:02 +1000 | [diff] [blame] | 7 | |
| 8 | # check that extra zero bytes don't change the internal int value |
| 9 | print(int.from_bytes(bytes(20), "little") == 0) |
| 10 | print(int.from_bytes(b"\x01" + bytes(20), "little") == 1) |