The Tower Bridge in Sacramento, California Parsing Concepts
Byte Ordering - Little Endian & Big Endian
Latest News
Getting Started
Screen Shots
About GOLD
How It Works
Why Use GOLD?
Revision History
Freeware License
More ...
What is a Parser?
Backus-Naur Form
DFA Lexer
LALR Parsing
More ...

Computers use data structures of all configurations. They range from the simple "byte" to 32-bit integers to those both complex and abstract. In most cases, the data structure consists of more than one byte. These bytes must be stored in memory and, sometimes, to files. However, the question remains: "When multiple bytes are used, what order are they stored in memory?"   This is a fundamental issue that must be know with absolute certainly, or the reading and writing of binary data could be interpreted incorrectly.

Two different classes of byte ordering are used in computers: Big-Endian and Little-Endian. When a data structure is stored in Little Endian format, the least significant byte is stored in the lower memory address. The opposite is true for Big Endian, the most significant byte is stored in the lower memory address.

For instance, assume you have a 32-bit integer containing the value D7C416. The least significant byte contains the value C416 and the most significant byte contains D716. If the number is stored using Little Endian byte ordering, the first byte in the file will contain the value C416; the second: D716. This is the format used on the Intel family of processors and is the standard used by most file formats.

At first you might consider the Little Endian format "backwards", but this is not the case. In Little Endian, the low memory byte is stored in the lower memory location in the file - what we would logically assume would happen. The "backwards" appearance of Little Endian is not a result of the order of the bytes, but instead from differences in the notation commonly used to represent numbers and files. In fact, it is these representations that are reversed.

Typically, hexadecimal numbers are printed with the high-order bit on the leftmost position; the rightmost bit being the least significant. In storage terms, the higher byte is displayed first; this being the case with the value D7C416. In other words, hexadecimal and binary numbers are normally displayed in descending order. On the other hand, when displaying the binary information in files, the low-order byte of the file is usually displayed first. In this case, files are displayed in ascending order.

If files were displayed with the high-byte first, the onscreen representation would look like the following:

This reversal of notations is what gives Little Endian the appearance of being "backwards".