What is Endianness?
Well, whenever a number is represented by more than one byte, the question arises as to the order in which the bytes are arranged. If the most significant bits come first, that is, are stored at the lowest memory address or at the first location in the file, the representation is said to be big-endian. If the least significant bits come first, the representation is said to be little-endian. Consider the following sequence of four bytes. The first row shows the bit pattern. The second row shows the interpretation of each byte separately as an unsigned integer. bit pattern00001101000001101000000000000011 decimal value1361283 Here is how this four byte sequence is interpreted as an unsigned integer under the two ordering conventions: Little-Endian (13 * 256 * 256 *256) + (6 * 256 *256) + (128 * 256) + 3218,529,795 Big-Endian (3 * 256 * 256 *256) + (128 * 256 *256) + (6 * 256) + 1358,721,805 Most computers these days are little-endian since the Intel and AMD processors that most PCs use ar
There are two fundamental sources of endian-related problems: • Programmer assumptions about the endianness of the processor on which a program will run • Endianness collision: a program running on a machine of one endianness having to deal with structured data (that is, not simply an array of bytes) exported from an environment of the other endianness
Endianness is the function of a system that details integer representation. It orders the way the numbers appear. Much like a spoken language, integers as part of codes must be translated onto paper. While some cultures read right to left and some read left to right, numbers in codes can also be arranged either from right to left or left to right. A system’s memory contains bytes, and each location in the system stores one element of the memory. These elements are usually bytes, although some systems store bits. One word or integer translates to 32 bits, or four bytes. Since each memory address can only store one byte, not four, the integer must split into individual bytes, which each use two digits to represent that byte’s value. The term endianness comes from the book Gulliver’s Travels by Jonathan Swift, where he satirically describes the differences between the way people eat boiled eggs—either from the big end or the little end. Hence, endianness comes in two varieties: big endian
In Jonathan Swift’s Gulliver’s Travels, the Lilliputians were split into two factions over the matter of which end of an egg to break open when consuming it. Big Endians broke their egg on the large end, while Little Endians broke it on the small end. In much the same way, computer designers are in a constant state of disagreement over which end of a multi-byte value to consume first. For simplicity, endianness in 32-bit numbers is often represented by the letters ABCD, where the letters are used to describe the order in which the most, second to most, second to least, and least-significant bytes are stored in memory. Little endian refers to storing the little end of a multibyte value at the lowest address. The number 513 in a 32-bit value, for example, is stored as 0x01020000 (DCBA), with the 02 representing 512, and the 01 representing the other 1. The address pointer for the start of the value points at the 01. Big endian refers to storing the big end of a multibyte value first. Thi