FERMATA HOLD LLCCompany information
Science & Technology
Chapter
02Representation
General technology reading

The order of bytes

Byte order defines how the bytes of a number are arranged. The same stored sequence can produce different values under different interpretations.

2.1

Position carries meaning

An eight-bit byte can represent only a limited range of values. Larger integers commonly use multiple bytes, with some bytes contributing more to the value than others. Big-endian order places the most significant byte at the lowest address. Little-endian order places the least significant byte there.

These names describe byte arrangement, not individual bit order on a wire or a file's meaning.

2.2

One value, two arrangements

Consider the hypothetical hexadecimal value 0x1234, comprising bytes 0x12 and 0x34. The lower address holds 0x12 in big-endian order, or 0x34 in little-endian order. The intended number remains the same.

If a reader assumes the opposite order, it can interpret those bytes as 0x3412 instead. The sequence may be perfectly intact while the resulting value is wrong.

Illustrative value: 0x1234
ArrangementLower addressNext address
Big-endian0x120x34
Little-endian0x340x12
2.3

Agree at the boundary

A file format or protocol should specify byte order. Programs can then translate between that representation and their internal arrangement. Explicit reading and writing rules make exchanges easier to inspect.

Field width, signedness, encoding and units also matter. Byte order alone cannot tell you what a field represents.