Endianness
Endianness is a data attribute that describes byte order. When applications exchange data, they need to know the ordering convention for multi-byte data. Otherwise, data can be misinterpreted.
Data can have the following byte order formats:
- Big endian
- A format in which the most significant byte is stored first. The other bytes follow in
decreasing order of significance. For example, for a four-byte word, the byte order is 0, 1, 2, 3.
For a two-byte word, it is 0, 1.
Big endian format is used by pSeries, IBM® Z, iSeries, Sun, and HP.
- Little endian
- A format in which the least significant byte is stored first.
The other bytes follow in increasing order of significance. For example,
for a four-byte word, the byte order is 3, 2, 1, 0. For a two-byte
word, it is 1, 0.
Little endian format is used by Intel-based machines, including xSeries.
Endianness affects only multi-byte data. Within a single byte, the bits are always ordered in the same way. Bit order within a byte is always 7, 6, 5, 4, 3, 2, 1, 0.
UTF-16 | UTF-321 | |
---|---|---|
Big endian | X'0041' | X'00000041' |
Little endian | X'4100' | X'41000000' |
Note:
|
Endianness becomes a potential problem when data is exchanged between systems and applications that use different endian formats and the data is not properly converted. Be aware of the endian format of the data that your system or application handles. You might notice endianness problems when looking at character encoding values in traces. Such a problem might exist if you notice that numeric byte values have been switched. For example, you expect X'0041' but see X'4100'.