What is endianness?

Endianness specifies the order in which the bytes of data are stored/processed by a computer.

For example, let’s consider a variable that is of 4bytes, and in the memory, it looks like this as shown below.

When we access the variable, all 4 bytes of data will be fetched from the memory and the resultant value will be computed. The question is, in which order the data is fetched from the memory? Is it from the lower address to the highest address or vice versa? Endianness defines in which order the data has to be interpreted. Computers follow two types of endianness.

  • Little Endian
  • Big Endian

Little Endian

In little-endian computers, the data is always stored from a lower address to a higher address i.e. LSB is always present at the lower address and MSB is at the higher address.

For example,

  • x86 and x64 architecture machines use little endian.

Big Endian

In Big endian computers, the data is stored from a higher address to a lower address i.e. MSB is always present at the lower address and LSB is at the higher address

For example

  • Atmel AVR32 and OpenRISC use big endian.
  • Networking protocols such as TCP, UDP, and ipv4, v6 use this format.

Categorized in:

Tagged in: