Endianness
Byte ordering
Byte ordering, or endianness, is the order in which we store bytes in memory and process them.
Link to original
Say we have a two-byte integer, we can choose where the least and most significant byte is stored:
Big-endian
Big-endian machines are where we store the most signfiicant byte followed by the least significant byte.
It is more natural. The sign of the number can be determined by looking at the byte at address offset . Strings and integers are stored in the same order.
Link to originalLittle-endian
Little-endian machines are where we store the least significant byte followed by the most significant byte.
Makes it easier to place values on non-word boundaries. Conversion from a 16-bit integer address to a 32-bit one does not require any arithmetic.
Link to original
Suppose we have the hex number , the big / small endian arrangements of the bytes are:
| Address | ||||
|---|---|---|---|---|
| Big Endian | ||||
| Little Endian |