Computer Science - Endianness
- Endianness: the order of the bytes
- big-endian: the most significant byte first
- little-endian: the least significant byte first
- Network byte order: big-endian
"0A 0B 0C 0D"
- Big-endian: stored as "0A 0B 0C 0D" in memory
- Little-endian: stored as "0D 0C 0B 0A" in memory
A 32-bit memory location with content 4A 00 00 00 can be read at the same address as either 8-bit (value = 4A), 16-bit (004A), 24-bit (00004A), or 32-bit (0000004A), all of which retain the same numeric value.
- big endian: Java, IBM z/Architecture mainframes, IPv6(network byte order)
- little endian: Intel x86 processor
>>> import struct >>> struct.pack("<I", 1) b'\x01\x00\x00\x00' >>> struct.pack(">I", 1) b'\x00\x00\x00\x01'
< means little-endian, and
> means big-endian.
I for 32-bit unsigned integer, so it takes 4 bytes. In little-endian, byte
\x01 is stored first, while in big-endian, it is stored last.
Check system byte order:
>>> import sys >>> sys.byteorder 'little'