What little endian means
Little endian stores the least significant byte of a number at the lowest memory address. Big endian stores the most significant byte first, which matches the way people write numbers.
The 32-bit value 0x12345678 shows the difference. The four bytes sit in these orders:
| Byte order | Byte 0 | Byte 1 | Byte 2 | Byte 3 |
|---|---|---|---|---|
| Big endian | 12 | 34 | 56 | 78 |
| Little endian | 78 | 56 | 34 | 12 |
Only the byte order changes. The two hex digits inside each byte stay in place, so 78 does not become 87.
How to convert little endian hex to decimal
- Split the hex into bytes of two digits each: E8 03 00 00.
- Reverse the order of the bytes: 00 00 03 E8.
- Convert the reversed hex to decimal: 0x000003E8 = 3 × 256 + 14 × 16 + 8 = 1,000.
A second example uses 78 56 34 12. Reversed, it reads 12 34 56 78, which is 305,419,896 in decimal. For the digit-by-digit method, see how to convert hex to decimal by hand.
Convert without reversing the bytes
Multiply each byte by 256 raised to its position, counting from 0 at the first byte. The first byte is the least significant, so no reversal is needed.
E8 03 00 00 = E8 × 256⁰ + 03 × 256¹ + 00 × 256² + 00 × 256³
= 232 × 1 + 3 × 256 + 0 + 0
= 232 + 768
= 1,000This method suits short fields, such as 2-byte lengths in a file header, where reversing by eye takes longer than the sum.
Signed little endian values
Reverse the bytes first, then read the result as two's complement at the full byte width. The sign bit is the top bit of the last byte in memory, not the first.
| Bytes in memory | Width | Unsigned | Signed |
|---|---|---|---|
| FF 7F | 16-bit | 32,767 | 32,767 |
| 18 FC FF FF | 32-bit | 4,294,966,296 | −1,000 |
| FF FF FF FF | 32-bit | 4,294,967,295 | −1 |
The bytes 18 FC FF FF reverse to FF FF FC 18, which is 4,294,966,296 unsigned and −1,000 signed, since 4,294,966,296 − 2³² = −1,000. The signed hex to decimal converter explains two's complement at every width.
Byte width changes the answer
The same bytes give different numbers when you read them at a different width, so include every byte of the field. Dropping zero bytes is the most common cause of a wrong result.
| Bytes | Little endian | Big endian |
|---|---|---|
| 01 00 | 1 | 256 |
| 2A 00 00 00 | 42 | 704,643,072 |
| 34 12 | 4,660 | 13,330 |
Bytes 2A 00 00 00 read as 42 only when you treat all 4 bytes as one 32-bit integer.
Where little endian and big endian appear
x86, x86-64 and most ARM systems store integers in little endian, and network protocols send them in big endian. Big endian is also called network byte order.
- Little endian: memory dumps and hex editor views on x86 and ARM machines, BMP and WAV files, and the registers and packets of many USB devices.
- Big endian: IP, TCP and UDP headers, PNG chunk lengths, and the protocol fields that packet analysers such as Wireshark display.
A packet capture shows port 80 as 00 50, so it needs no reversal. The same port stored in memory on an x86 machine appears as 50 00. For IP addresses in both orders, use the hex to IP address converter. For floating-point bytes, see the hex to float converter.
Little endian hex to decimal in code
Python
int.from_bytes(bytes.fromhex("E8030000"), "little") # 1000
int.from_bytes(bytes.fromhex("18FCFFFF"), "little", signed=True) # -1000JavaScript
const b = new Uint8Array([0xE8, 0x03, 0x00, 0x00]);
new DataView(b.buffer).getUint32(0, true); // 1000
new DataView(b.buffer).getUint32(0, false); // 3892510720 (big endian)The second argument of getUint32 is true for little endian. See hex to decimal in JavaScript for parseInt and BigInt.
C
#include <stdint.h>
uint8_t b[4] = {0xE8, 0x03, 0x00, 0x00};
uint32_t v = (uint32_t)b[0] | (uint32_t)b[1] << 8 | (uint32_t)b[2] << 16 | (uint32_t)b[3] << 24; // 1000The shift version gives 1,000 on any processor. Copying the bytes with memcpy into a uint32_t gives 1,000 only on a little endian machine. For Python struct formats such as <I, see hex to decimal in Python.
Frequently asked questions
How do you convert little endian hex to decimal?
Do you reverse the hex digits or the bytes?
What is the difference between little endian and big endian?
Why do processors use little endian?
Where do the names little endian and big endian come from?
How do you read a hex dump that mixes byte orders?
Related tools
- Hex to decimal converter — convert big endian hex with digit-by-digit steps
- Signed hex to decimal — two's complement at 8, 16, 32 and 64 bits
- Hex to IP address — network and host byte order for addresses
- Hex to float — IEEE 754 values from raw bytes