Skip to the workspace
Pebellslearn by building
Binary, Hex and Endianness  ›  Capstone Project

Little Endian — Least Significant Byte First

Little Endian 12 minA little-endian machine stores a multi-byte number with its least significant byte at the lowest memory address, so the bytes appear reversed compared with how the number is written.

computer science / Little Endian — Least Significant Byte First

Explore each scene at your own pace.

01 · The rule

The rule

Little Endian — Least Significant Byte First

Open a memory dump on almost any laptop or phone, look for the number 0x12345678, and you will find the bytes 78 56 34 12. The number has not been scrambled. Most processors today, including x86 chips and ARM chips in their usual mode, are little endian: they store the little end first.

The rule

Little endian: the little end, the least significant byte, goes first.

The least significant byte is the one worth the least, the rightmost hex pair. Little endian puts it at the lowest address:

0x12345678, little endian:
address:  100  101  102  103
byte:      78   56   34   12

Why would anyone choose this? One reason: the byte at the starting address is always the ones byte, whatever the width. The number 5 stored in 8 bytes begins with 05 at the same address as 5 stored in 4 bytes, and addition starts from the low byte just as you add from the rightmost digit.

The real danger is a mismatch: bytes written in one order and read in the other. Suppose a little-endian program writes the 32-bit number 1 as raw bytes: 01 00 00 00. A reader that assumes big endian sees 0x01000000, which is 16,777,216. Nothing crashes; the number is just silently wrong. This is why file formats and protocols state their byte order, and why programs convert explicitly when they read or write binary data.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.