Big or little endian, which is best?
A better question to ask is:
Should you view data Left-to-right (LTR) or Right-to-left (RTL)?
And the answer to that is: It depends on what you are looking at.
Texts...
...like for example "abcd" is typically displayed LTR in most countries.
And if one is to place the individual characters in memory it feels natural to put the "a" in the lowest address.
Byte address
|
0
|
1
|
2
|
3
|
Byte value
|
"a"
|
"b"
|
"c"
|
"d"
|
Numbers...
...on the other hand have (at least in computer science contexts) their individual parts (bits) counted from the
Least_significant_bit which is displayed furthest to the right (The number is displayed RTL).
Example: 769 (0x0301):
Bit address
|
15
|
14
|
13
|
12
|
11
|
10
|
9
|
8
|
7
|
6
|
5
|
4
|
3
|
2
|
1
|
0
|
Number value
|
769 (0x0301)
|
Byte value
|
0x03
|
0x01
|
Bit value
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
1
|
0
|
0
|
0
|
0
|
0
|
0
|
0
|
1
|
Example
Assume you have 6 bytes consisting of a binary number such as 769 (0x0301) followed by the text "abcd".
Lets view the data LTR
Byte address
|
0
|
1
|
2
|
3
|
4
|
5
|
Byte value
|
0x0301*
|
"a"
|
"b"
|
"c"
|
"d"
|
Bit value
|
0b00000011_00000001*
|
"a"
|
"b"
|
"c"
|
"d"
|
*Endianness undetermined.
Big endian feels right...
... since the
Most_significant_byte is to the left of the
Least_significant_byte:
Byte address
|
0
|
1
|
2
|
3
|
4
|
5
|
Byte value
|
0x03
|
0x01
|
"a"
|
"b"
|
"c"
|
"d"
|
Bit value
|
0b00000011
|
0b00000001
|
"a"
|
"b"
|
"c"
|
"d"
|
If we are going through the memory, looking at the byte address 0 and on the lowest bit we see the 8th bit of the binary number!!!! then continuing upwards we find [8, 9, 10, 11, 12, 13, 14, 15, 0, 1, 2, 3, 4, 5, 6, 7] which is in the
wrong order!!!
Lets view the data RTL
It feels natural with low endian (lowest byte (counted by significance) has the lowest address)
Byte address
|
5
|
4
|
3
|
2
|
1
|
0
|
Byte value
|
"d"
|
"c"
|
"b"
|
"a"
|
0x03
|
0x01
|
Bit value
|
"d"
|
"c"
|
"b"
|
"a"
|
0b00000011
|
0b00000001
|
Of course the text comes in the wrong order, which might seem like a problem for developers who deals with file-formats, but not so much for developers who deals with CPUs.
Summary
Anyone focusing on the character-order in a text will prefer LTR and big-endian.
Anyone focusing on the bit-order within a number will prefer RTL and little-endian.
- At the core of the problem is that:
Individual characters in a text are counted LTR
Individual bits in a number are counted RTL