Endianness

In computing, the term endian or endianness refers to the ordering of individually addressable sub-components within the representation of a larger data item as stored in external memory (or, sometimes, as sent on a serial connection). Each sub-component in the representation has a unique degree of significance, like the place value of digits in a decimal number. These sub-components are typically 16-, 32- or 64-bit words, 8-bit bytes, or even bits. Endianness is a difference in data representation at the hardware level and may or may not be transparent at higher levels, depending on factors such as the type of high level language used.

The most common cases refer to how bytes are ordered within a single 16-, 32-, or 64-bit word, and endianness is then the same as byte order. The usual contrast is whether the most significant or least significant byte is ordered first—i.e., at the lowest byte address—within the larger data item. A big-endian machine stores the most significant byte first, and a little-endian machine stores the least significant byte first. In these standard forms, the bytes remain ordered by significance. However, mixed forms are also possible where the ordering of bytes within a 16-bit word may differ from the ordering of 16-bit words within a 32-bit word, for instance. Although rare, such cases do exist and may sometimes be referred to as mixed-endian or middle-endian.

Endianness is important as a low-level attribute of a particular data format. For example, the order in which the two bytes of a UCS-2 character are stored in memory is of considerable importance in network programming where two computers with different byte orders may be communicating with each other. Failure to account for a varying endianness across architectures when writing code for mixed platforms leads to failures and bugs that can be difficult to detect.

Endian First byte
(lowest address)
Middle bytes Last byte
(highest address)
Decimal 1000 (hexadecimal 3E8) in two bytes Notes
big most significant ... least significant 03 E8 Similar to a number written on paper (in Hindu-Arabic numerals as used in most Western scripts)
little least significant ... most significant E8 03 Arithmetic calculation order (see carry propagation)

The term endian as derived from end may lead to confusion. Note that it denotes which end (i.e., outermost part) of the number comes first rather than which part comes at the end of the byte sequence (representing the number). See Etymology for an explanation why it refers to the end from which something starts, but not to something coming last.

Read more about Endianness:  Endianness and Hardware, Endianness and Operating Systems On Architectures, Etymology, History, Optimization, Diagram For Mapping Registers To Memory Locations, Examples of Storing The Value 0A0B0C0Dh in Memory, Endianness in Networking, Endianness in Files and Byte Swap, "Bit Endianness", Other Meanings