Endianness
Endianness is the byte ordering of multi-byte values in memory: big-endian stores the most significant byte first, little-endian the least significant byte first.
Purpose
It resolves how multi-byte data is stored and transmitted consistently across CPU architectures.
Mechanism
Big-endian: the most significant byte sits at the lowest address (0x010203 stored as 01 02 03), the convention for network protocols. Little-endian: the least significant byte sits at the lowest address (stored as 03 02 01), used by x86/ARM. UTF-16/32 require a BOM or an explicit endianness declaration.
Use cases
- Network protocol fields (network byte order is big-endian)
- Binary file formats (e.g., PNG is big-endian, ELF little-endian)
- Cross-platform data serialization
- Embedded and driver development
Examples
- Input
0x01020304OutputBE: 01 02 03 04 / LE: 04 03 02 01The same value in both byte orders
Common errors
- Sending host-order integers without network byte order conversion
- Convert explicitly with htonl/ntohl or DataView
Related terms
Byte Order Mark
The byte order mark (BOM) is the U+FEFF character placed at the start of Unicode text to indicate the encoding form and byte order. GLOSSARY
UTF-16
UTF-16 is Unicode's variable-length encoding form, using 2 or 4 bytes per code point: BMP characters take one 16-bit code unit and supplementary-plane characters take a surrogate pair (2 code units). GLOSSARY
Binary
Binary is the base-2 numeral system, using only 0 and 1, and is the foundation of internal data representation in all digital electronic computers. GLOSSARY
BOM
The BOM (byte order mark) is the Unicode character U+FEFF, placed at the start of a text stream to indicate the encoding form and byte order. GLOSSARY