Home / Guides / Endianness (byte order)

Endianness (byte order)

Endianness is the order in which a multi-byte number is stored in memory.

Big-endian and little-endian

Big-endian stores the most significant byte first (at the lowest address), while little-endian stores the least significant byte first.

Example

Storing hex 0x1234, big-endian places the bytes as 12 34, and little-endian as 34 12.

x86 CPUs are little-endian, while network protocols usually use big-endian (network byte order).

Why it matters

When two systems of different endianness exchange binary data, values come out reversed unless the byte order is matched.