Endianness: Byte Order & Practice
Endianness: Byte Order & Practice
This page explains endianness, the order in which bytes of a multi-byte value are stored or transmitted, and why it matters in computing.
Word size and bytes
Modern computers usually have a word size of 32 or 64 bits. If a value is larger than one byte, it must be split across multiple bytes. The question is: which byte comes first when storing or transmitting the value?
Big endian and little endian
- Big endian: the most significant byte (MSB) comes first.
Example: 0x1A2B3C4D is stored as 1A 2B 3C 4D.
- Little endian: the least significant byte (LSB) comes first.
Example: 0x1A2B3C4D is stored as 4D 3C 2B 1A.
Both are valid systems. Writer and reader must agree, otherwise values are misinterpreted.
Origins of the terms
The terms big endian and little endian were coined in 1980 by Danny Cohen. They refer humorously to Jonathan Swift’s “Gulliver’s Travels,” where factions fought over which end of a boiled egg should be opened.
CPU architectures
- Intel x86: little endian.
- SPARC, PowerPC, Motorola 680x0: big endian.
- Some CPUs support both (e.g., ARM, Alpha, newer PowerPC).
Protocols and file formats
- Most network protocols, including IP, use big endian.
- File formats vary: PNG and JPEG are big endian, TIFF specifies its byte order in the header.
Practical example
Value: 0x12345678 (32-bit)
Big endian storage: 12 34 56 78
Little endian storage: 78 56 34 12
If interpreted incorrectly, the value will appear completely different.
No better system
Endianness is like writing direction in natural languages. Neither system is inherently better; consistency matters most. What matters is that both ends of communication use the same convention.