byte order


byte order

The way numbers are stored in a computer word, which is the basic unit of storage (computer words are 8, 16, 32 and 64 bits long).

Big Endian and Little Endian
Big endian is the way we normally deal with numbers: the most significant byte or digits are placed leftmost in the structure (the big end). The Internet protocol (TCP/IP) also uses the big endian order regardless of the hardware at either end.

Some CPUs, most notably x86 CPUs, deal with words in little endian order, which places the least significant digits on the left (the little end). Since numbers are calculated by the CPU starting with the least significant digits, little endian numbers are already set up in the required processing order.

Bi-Endian
A bi-endian machine, such as the PowerPC, supports both big endian and little endian words.

In the following example, the decimal number 23,041 (equivalent to 5A01 in hex) is shown in both byte orders.

BYTE ORDER FOR NUMBER 23,041 (5A01 in hex)Big Endian (BE) Little Endian (LE) 5A01 015A CPU BYTE ORDER EXAMPLESBig Endian Little Endian Motorola 68K x86 (Intel, AMD, etc.) IBM mainframes PDP-11, VAX Bi-Endian CPUs PowerPC Itanium



Choosing Byte Order
TIFF images store pixel values as words, and byte order makes a difference; witness this Photoshop dialog box asking which platform you are saving to. On the other hand, GIFs and JPEGs are not word oriented, and byte order does not matter.