Endianness
Endianness refers to the order in which bytes are stored and read in a computer's memory.
To understand it, imagine reading directions in different languages: while English text flows from left to right, Arabic Hex flows from right to left.
Similarly, computers have two ways to store data:
- Big-endian (BE): Most significant byte first
- Little-endian (LE): Least significant byte first
1. Big-Endian
Big-endian stores the most significant byte first. This is similar to how humans read numbers and Hex in most cases: starting with the most important information.
Example: Storing the number 12345678 (hexadecimal:
0x00BC614E
) in memory:- Big-endian order:
00 BC 61 4E
- Most significant byte (
00
) is at the lowest memory address. - Least significant byte (
4E
) is at the highest address.
Big-endian is considered more "human-readable" because the data is stored in the order we naturally read it.
2. Little-Endian
Little-endian stores the least significant byte first. While counterintuitive to humans, it's more efficient for modern processors.
Example: Storing the number 12345678 (
0x00BC614E
) in memory:- Little-endian order:
4E 61 BC 00
- Least significant byte (
4E
) is at the lowest memory address. - Most significant byte (
00
) is at the highest address.
This "reversal" is common in Bitcoin's internal data representation.
3. Endianness in Bitcoin
Bitcoin primarily uses little-endian for storing data like ...