EMZETT.
Login

Endianness (byte order)

In short: Endianness describes the order in which the bytes of a multi-byte number sit in memory. With little-endian the least significant byte comes first, with big-endian the most significant.

In more detail: The 32-bit number 0x12345678 consists of the bytes 12 34 56 78. A big-endian system stores it exactly like that, a little-endian system as 78 56 34 12. Both are valid; problems arise only when two systems exchange data.

In Depth

  • Little-endian: x86 and most everyday ARM systems.
  • Big-endian: Network protocols (“network byte order”), some older architectures.
  • Conversion: Functions such as htons and htonl convert numbers to network order.
  • File formats: Some record the order in the header (for example TIFF), others prescribe it.
  • Symptom: Numbers look “completely wrong” when bytes are read swapped.

See also: UTF-8 and character encoding