Endianess

From Rice Wiki
Revision as of 07:00, 2 April 2024 by Rice (talk | contribs)

CPUs operate on a group of bits called a word. A 32-bit CPU has a 32 bit (4 byte) word size. Endianess is the choice of order when storing multiple bytes of a word across memory. There are two choices: Big Endian and Little Endian.

Consider storing 0x10203040 in a 32-bit machine

In Big Endian, the most significant byte is stored at the lowest part of an address (i.e. big end first). Addresses would look something like 0x10, 0x20, 0x30, 0x40. BE is used on the internet.

In Little Endian, the least significant byte is stored at the lowest part of an address (i.e. little end first). Addresses would look something like 0x40, 0x30, 0x20, 0x10. LE is used on intel machines.

Most file formats specify endianess. For example, a Unicode text file has a BOM (byte order mark) at the start to denote whether the file is BE or LE.