What’s Endianness?

Print anything with Printful



Endianness determines how integers are represented in a system’s memory. Big endian places the most significant byte to the left, while little endian places it to the right. Network byte order is used when endianness is unclear.

Endianness is the function of a system that details the representation of integers. Sort the way numbers appear. Just like a spoken language, integers as part of codes need to be translated on paper. While some cultures read right-to-left and some read left-to-right, the numbers in codes can also be arranged right-to-left or left-to-right.

A system’s memory contains bytes, and each location in the system stores one item of memory. These items are usually bytes, although some systems store bits. One word or integer translates into 32 bits or four bytes. Since each memory address can only store one byte, not four, the whole must be broken up into individual bytes, each of which uses two digits to represent the value of that byte.

The term endianness comes from Jonathan Swift’s book Gulliver’s Travels, where it wryly describes the differences between how people eat hard-boiled eggs, from both the big and small ends. Hence, endianness comes in two varieties: big endian and little endian. A big endian arrangement takes an integer consisting of multiple bytes and places the most significant of these bytes to the left. The most significant byte is stored in the smallest address. This sort of byte ordering is easy to understand for speakers of languages ​​such as English, where text is read from left to right.

A little endian arrangement is one where the most important byte in a multibyte integer will be on the right. Here, the least significant byte is stored in the smallest address. This allows for right-to-left reading, like Hebrew and Arabic. To keep byte order neat, remember that when the least significant byte (LSB) is stored first, it is called little endian. When the most significant byte (MSB) is stored first, it is called big endian.

All systems are big or little endian and some have a register bit, which allows the user to choose the preferred endian. When storing integers in a system file, the file may be sent to a machine that uses the other type of endianness. The numbers would go backwards and the message would make no sense. Generally, when it’s not clear which endianness to use, something called network byte order comes into play. With this, integers are sent in groups of four bytes of big or little endianness, chosen at random, and the machine receiving the integers can swap the bytes if the endiannesses don’t match.

Endianness is only used when breaking something of great value, like a word, into smaller pieces. An order is then formed in which to store these parts in system memory. Not used when storing a value in a register that can hold it all. In this case, all bits, left and right, are equally important.




Protect your devices with Threat Protection by NordVPN


Skip to content