What is the difference between little-endian and big-endian byte order?
Endianness is the order in which the bytes of a multi-byte value are stored in memory: little-endian puts the least significant byte at the lowest address, big-endian the most significant.
* Little-endian (x86) stores the least-significant byte at the lowest address; big-endian (network order) stores the most-significant first. *
A 4-byte number has to be laid out byte-by-byte, and there are two sensible orders. For the value 0x12345678:
| Address | Little-endian | Big-endian |
|---|---|---|
| 0x00 | 0x78 (LSB) | 0x12 (MSB) |
| 0x01 | 0x56 | 0x34 |
| 0x02 | 0x34 | 0x56 |
| 0x03 | 0x12 (MSB) | 0x78 (LSB) |
x86 and x86-64 are little-endian — the "little end" (least significant byte) comes first. This is exactly what you must remember when reading a memory dump in a debugger: bytes appear "backwards" relative to how you'd write the number.
When it bites you:
- Network protocols use big-endian ("network byte order"), so cross-machine data needs byte-swapping.
- Binary file formats and cross-platform data exchange must agree on endianness or numbers come out scrambled.
Memory trick: Little-endian → little (least significant) end stored first.
Go deeper:
Endianness (Wikipedia) — the canonical article on byte ordering, with per-address diagrams.