Skip to content
GK LibraryA home for curious minds
English

The computer that reads the same number backwards: Endianness

What would happen if two people received the same letter, and one read it from left to right while the other read it from right to left? Something very similar actually happens in the world of computers. Computers differ in the order in which they place the bytes of a multi-byte number in memory, and the word for this order is “endianness.”

Endianness, put simply, means “the order that decides which byte comes first when a value made of several bytes is stored in memory or transmitted.” The name comes from Jonathan Swift’s 1726 novel Gulliver’s Travels. In the novel, the people of Lilliput and Blefuscu go to war over whether a boiled egg should be cracked at the big end or the little end. In 1980, computer scientist Danny Cohen compared the debate over byte order to this egg war in his paper “On Holy Wars and a Plea for Peace,” and spread the terms big-endian and little-endian.

In this article, we will look in turn at why endianness exists, the difference between big-endian and little-endian, the problems that arise when computers with different endianness meet, and how endianness is handled today.


Which end of the egg to crack first: endianness

1. Why does endianness exist?

A green computer memory module lined with black memory chips lies at an angle on a dark desk, lit by blue light

Computer memory is addressed in units of bytes (8 bits). A single integer, however, usually occupies several bytes, such as 2, 4, or 8 bytes. So when one value is split across several cells, someone has to decide which byte goes first.

(1) Byte-level addresses
Each cell of memory has its own address, such as 0, 1, 2, and so on, and each cell holds only 1 byte. Storing a single 4-byte integer therefore takes four consecutive cells.

(2) High-order and low-order places
In the hexadecimal value 0x12345678, 12 is the most significant byte, holding the highest place, and 78 is the least significant byte, holding the lowest place. The order in which these four bytes are placed, starting from the lowest address, is exactly what endianness means.

(3) A choice with no right answer
Either order gives the same calculation results as long as it is used consistently within a single computer. Early computer makers therefore each chose the order that suited their designs, and that difference continues to this day.


2. The difference between big-endian and little-endian

On a wooden breakfast table in morning sunlight, two white ceramic egg cups each hold a boiled egg, one cracked at the rounded big end and the other at the pointed small end

Suppose we store 0x12345678 in four cells starting at address 100. The big-endian method places the bytes from address 100 in the order 12, 34, 56, 78, while the little-endian method places them in reverse: 78, 56, 34, 12.

Endianness infographic: under the title “Endianness: The Order of Bytes”, 0x12345678 is split into four blocks (navy 12, blue 34, light blue 56, orange 78) labeled “Most significant byte” and “Least significant byte”. Below, two rows of memory cells at addresses 100–103: the “Big-endian” row next to an egg cracked at the big end holds 12, 34, 56, 78, and the “Little-endian” row next to an egg cracked at the small end holds 78, 56, 34, 12 via crossing dashed arrows
Even for the same value 0x12345678, big-endian places the highest place in memory first, while little-endian places the lowest place first.
  • Big-endian: a method that puts the most significant byte at the lowest address, matching the order in which people write numbers.
  • Little-endian: a method that puts the least significant byte at the lowest address, used by Intel x86-family processors.
  • Bi-endian: a design that supports both methods, as in ARM and PowerPC.
  • Most Significant Byte: the byte that holds the highest place in a value, often abbreviated MSB.

(1) Strengths of big-endian
Reading memory contents from the front, the number appears in the order it is written, which makes it easy for people to check. Processors such as IBM mainframes and the Motorola 68000 used this method.

(2) Strengths of little-endian
Because the lowest place sits at the lowest address, reading 1 byte, 2 bytes, or 4 bytes from the same address still gives the correct lower part of the value. It also fits naturally with addition, which calculates carries starting from the lowest place.

(3) Separate from bit order
Endianness usually refers to the order in which bytes are placed. The order of bits within a single byte rarely matters to programs, because processors handle a byte as a single unit.


3. When computers with different endianness meet

Under a warm desk lamp, two laptops face each other on a wooden desk, connected by a single blue network cable

Within a single computer, endianness is almost invisible. Problems arise when data is passed through a file or a network to a computer with a different endianness.

(1) Numbers read backwards
When a little-endian computer stores the integer 1 in 4 bytes, it becomes 01 00 00 00. If a big-endian computer reads these bytes as they are, it gets 0x01000000, a nonsensical value of 16,777,216.

(2) The NUXI problem
When data from the PDP-11, which used little-endian order in 16-bit units, was moved to a machine using a different method, the letters “UNIX” could end up being read as “NUXI.” Each pair of bytes had been swapped, and the name became a nickname for byte-order problems.

(3) Bugs that are hard to find
Because values look fine when testing between machines of the same type and go wrong only when connected to a different type, finding the cause can take a long time.


4. How endianness is handled today

A network switch mounted in a server room rack, with blue and gray network cables neatly plugged into each port and small green indicator lights glowing

Since the difference in endianness cannot be eliminated, developers solve the problem by agreeing in advance on the order used when exchanging data.

(1) Network byte order
The Internet protocols (TCP/IP) adopted big-endian as the standard order. That is why languages such as C use functions like htonl (host to network long) and ntohl to convert the order before sending and after receiving.

(2) Orders fixed by formats
Java class files are defined as big-endian, and the UTF-16 character encoding places a byte order mark (BOM) at the very beginning: FE FF indicates big-endian and FF FE indicates little-endian.

(3) The dominance of little-endian
With x86 and most ARM devices running in little-endian mode, little-endian has effectively become the mainstream for today’s personal computers and smartphones. Even so, big-endian remains in networks and many file formats, so conversion is still necessary.

Just as an egg tastes the same whichever end you crack first, endianness is not a question of which side is right, but of agreeing on a convention. The simple idea of settling the order before passing data along—that is the first step toward understanding endianness.

Keep this article as a PDF

Buy the selected-language edition of the article you are reading.

US$1.00
Selected language: English

US$1.00 · one article · one language

Pay once, then log in to the same account to download your purchased edition again.

Preview a PDF sample ↗The article remains free to read. The sample shows the PDF typography and layout.

Seller information

Business name
아카이지
Representative
안호원
Business registration No.
530-02-04118
Mail-order sales report No.
2026-경기군포-0626
Reporting authority
경기도 군포시
Business address
경기도 군포시 산본천로 119-9, 1109동 405호 (산본동, 주공아파트)
Hosting provider
카페24(주)
Contact email
sgjjojo@gmail.com
Contact number
010-4194-0821

Verify seller information (Korea FTC)