Big And Little Endians
posted on September 16th, 2013
Somewhat basic but not used often so here is a refresher.
Endianness Is Determined By The CPU
Whether a computer is big-endian or little-endian depends on the cpu in the machine. The endianness of the processor is the endianness of the computer. RAM and hard-drives don't have endianness.
All Computers Read A Single Byte From Left To Right
Whether a computer is big-endian or little-endian an individual byte is read from left to right.
- 1 byte big-endian: 0x2E
- 1 byte little-endian: 0x2E
So, byte 0x2E (i.e. 00101110) on both big-endian and little-endian computers is 0x2E.
Endianness Is About The Order Of Multiple Bytes
Since all computers read single bytes from left to right endianness only matters when reading multiple bytes.
- 2 bytes big-endian: 0x1234
- 2 bytes little-endian: 0x3412
Bytes are written in reverse order depending on the endianness.