About Endian
In computing, the term endian or endianness refers to the ordering of individually addressable
sub-components within a longer data item as stored in external memory (or, sometimes, as sent
on a serial connection). These sub-components are typically 16- or 32-bit words, 8-bit bytes, or
even bits. Endianness is a difference in data representation at the hardware level and may be
transparent (or not) 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.[1] The usual contrast is whether the most-
significant or least-significant byte is ordered first (at the smallest address) within the larger data
item, which is known as big-endian and little-endian respectively. 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 fairly 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 an 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.