Endianness

Endianness

Refers to the ordering of bytes in memory. Processor-, not OS-dependent.

Big-endian machines store integers (two bytes) with the "big end" in the lower address. Example: Sun Sparc-based machines. Little-endian machines store integers with the "little end" in the lower address. Example: x86.

So when you write an integer to a file on a big-endian box and you read the same file on a little-endian box, you have an error. Thus, some file formats specify whether they're big- or little-endian (BMP specifies little-endian, CCSDS specifies big-endian).

The same error also occurs when you write integers to a socket on a big-endian box and read the same socket on a little-endian box. That's why the Internet Protocol specifies that all numeric values must be in "network byte order", which is big-endian.

There are several solutions.

Note: