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 12Why 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.
The shortcut
Split the number into byte pairs and reverse the pairs, not the digits. To read little-endian bytes back, reverse them again and read as normal.
Take the bytes in address order
34 then 12.
The trap: reversing digits instead of bytes. Reversing 0x1234 digit by digit gives 0x4321, which is wrong. Reversing by byte pairs gives 34 12, which is right.
Drills
Answer fast — trust the rule.
How is 0xA1B2C3D4 laid out in little endian, lowest address first?
Four bytes in memory are 01 00 00 00. What 32-bit number do they mean on a little-endian machine?
The same bytes 01 00 00 00 are read as a big-endian 32-bit number. What value results?
Which kind of data is safe to share between big- and little-endian machines without conversion?
Remember
- Little endian stores the least significant byte at the lowest address.
- Reverse byte pairs, never single digits: 0x1234 is stored as 34 12.
- The trap: mixing orders gives silently wrong numbers, so formats must state their byte order.
