Blockchain Semantics Insights
Business Case | Deep Tech | Announcements | Blockchain Glossary |
Big Endian And Little EndianBy Anurag Srivastava | June 16, 2018, 5:36 a.m. GMT
If you do not come from a Computer Science background but you code, there is a good chance that you haven't heard of Little-Endian and Big-Endian. In this post, we’ll give you a sneak-peak at the concept while talking about what role it plays in the bitcoin blockchain ecosystem.
Your computer stores information in a hard drive, which structures itself into a sequence of memory slots. Each of these slots has a unique memory address and their size may vary depending on the storage device. The slot size is called the atomic element size. A few examples of atomic element size are 1-bit, 8-bit, 16-bit. What this means is that for a 1 bit slot size, every memory slot will store information worth1-bit.
For example, let's consider number 42. When we do a binary conversion, we get 00101010.
There are two ways in which this is interpreted. The zero in red is the most significant or the leftmost bit and the zero in green is the least significant or the rightmost bit.
Endianness is the sequential order in which the bits/bytes are arranged when stored in memory or transferred digitally. Let's continue with our example of 42 to understand endianness better. There are two ways in which 00101010 can be stored in memory.
When we store the least significant bit at the first memory address, it is called as little endian way of storing information in memory.
When we store the most significant bit at the first memory address, it is called as big endian way of storing information in memory.
As represented in the two figures above, little endian is when the least significant value goes to the first memory address and big endian is when the most significant value goes into the first memory address.
Note that the computer processors accept/understand either the little or big endian formats; these two formats are not compatible with each other.
So, if the information is generated from a system with the little-endian processor and it is electronically transmitted to a system with big ,endian processor, the second system will not be able to consume it. There must be an explicit conversion made before it can be processed by the consumer processor.
Big endian order is the most one that has been adopted currently and is, therefore, also referred to as the network byte order.
Endianness in Bitcoin Blockchain
Bitcoin Blockchain network uses the little-endian format by default. The transaction and header hashes are also stored in the little-endian format. However, experts would say that the big-endian format is preferable so that the transmitted blockchain transactions would be consumed by most of the systems without requiring any specific conversions.
If you know of any specific reasons behind this design decision of the Bitcoin protocol, please let us know in the comments section.