Endianness (byte order)

  • Endianness defines how multi-byte values are laid out in memory—specifically, the order in which bytes are stored.

  • Endianness decides which byte goes at the lowest memory address.

  • Endianness does NOT change:

    • Bit order inside a byte

    • The numeric value

    • Register behavior

  • It only affects:

    • Memory representation

    • Serialization / binary I/O

Little-endian

  • Least significant byte stored first (lowest address)

  • Most systems today are little-endian.

value:     0x12345678
Address:   +0   +1   +2   +3
Memory:    78   56   34   12   (little-endian)
  • Used by:

    • x86 / x86-64

    • ARM (default today)

    • most modern systems

Big-endian

  • Most significant byte first

Value:     0x12345678
Address:   +0   +1   +2   +3
Memory:    12   34   56   78
  • Used by:

    • some networking protocols

    • older architectures (e.g., PowerPC in certain modes)