<p>To add onto RedGrittyBrick's answer, little endianness is a result of using little endian CPUs, and then sending data as it is stored in memory.</p>
<p>On little endian architectures, integers in memory are stored as little endian. When preparing messages to be sent over the network, Satoshi's serialization functions would simply copy the memory directly, thus inheriting the way that such data is stored in memory.</p>
<p>I believe the only exception to this is the uint256 implementation which is used for storing all 256 bit hashes. This appears to be deliberately written to interpret these integers as little endian.</p>
<p>Otherwise, the 0.1.0 client was written in a way that would not have been compatible with big endian architectures. If it were compiled for and ran on a big endian CPU, I think it would incorrectly deserialize integers. However the endianness used in the vast majority of computers is little endian, so this was unlikely to have caused an issue, not to mention that Windows isn't available on any big endian architectures anyways.</p>

CC BY-SA 4.0
2023-05-23T22:37:17.347Z
2023-05-23T22:37:17.347Z
Ava Chow
<p>It is probably because Satoshi Nakamoto was sometimes rather careless.</p>
<p>It is a deviation from established standards that I would say has no sufficiently good reason in this particular case.</p>
<p>Just as interoperability among different Bitcoin node implementations is guided by Bitcoin Improvement Proposals (BIPs), interoperability among computers on the internet is guided by a system of Requests For Comments (RFCs). It seems likely that the BIP process was loosely modeled on the earlier RFC process.</p>
<p>RFC1700 by Reynolds and Postel in 1994 says</p>
<blockquote>
<p>When a multi-octet quantity is transmitted the most significant octet is
transmitted first.</p>
</blockquote>
<p>That is to say that &quot;Network Order&quot; is big-endian.</p>
<p>Computer hardware (the CPU etc) can be little-endian or big-endian. An application running on a little-endian machine is expected to translate to and from big-endian when communicating over the Internet. networking libraries provide for this. Most network protocols and applications do this.</p>
<p>Satashi Nakamoto failed to do this properly.</p>

CC BY-SA 4.0
2023-05-23T15:23:06.283Z
I should probably add that clumsy mortal imperfect heroes are still heroes.
RedGrittyBrick
CC BY-SA 4.0
2023-05-24T07:53:57.223Z
There is a very obvious good reason. Byte order conversions take time and the vast majority of computers impelementing this protocol are little-endian.
David Schwartz
CC BY-SA 4.0
2023-05-23T09:15:06.283Z
2023-05-24T10:49:08.743Z
2023-05-24T10:49:08.743Z
RedGrittyBrick
<p>There isn't any other reason for use of little-endian format than just the agreement made among programmers who implemented it. Bitcoin would have worked equally well with big-endian format.</p>

CC BY-SA 4.0
2023-05-23T09:01:22.407Z
2023-05-23T09:01:22.407Z
Greg Tonoski
<p>As far as I know Satoshi never explained why both big endian and little endian are used in the Bitcoin protocol. Some of the reasons for using little endian generally are discussed <a href="https://softwareengineering.stackexchange.com/questions/95556/what-is-the-advantage-of-little-endian-format">here</a> but I don't know to what extent they apply to its usage in Bitcoin.</p>

CC BY-SA 4.0
2023-05-23T09:10:47.900Z
2023-05-23T09:10:47.900Z
Michael Folkson
<p>I've noticed just from studying the raw hex values of transactions that many components are formatted in hexidecimal little endian.</p>
<p>For example, the amount specified in an output will be formatted as <code>b6f5050000000000</code> instead of <code>0005F5B6</code>, which represents 390,582 satoshi.</p>
<p>To be honest, I have a basic general understanding of big-endian vs little-endian but why is the little-endian format used? And why not just use the normal hex string format like <code>0005F5B6</code> in the example above?</p>

CC BY-SA 4.0
2023-05-24T08:50:57.070Z
Does this answer your question? [Why does the Bitcoin protocol use the little-endian notation?](https://bitcoin.stackexchange.com/questions/2063/why-does-the-bitcoin-protocol-use-the-little-endian-notation)
Vojtěch Strnad
CC BY-SA 4.0
2023-05-25T03:06:23.267Z
The replies on this thread and from the link you sent me both give me a better understanding of it. And it does seem like it has more to deal with lower level programming which I am not an expert in. Nonetheless, good education for myself.
jiamijiang
<raw-transaction><output><endianness>
Why is little endian used in transaction formatting and other parts of bitcoin?
jiamijiang
# Why is little endian used in transaction formatting and other parts of bitcoin?

(Asked by: username_0 on 2023-05-23)

I've noticed just from studying the raw hex values of transactions that many components are formatted in hexidecimal little endian.

For example, the amount specified in an output will be formatted as `b6f5050000000000` instead of `0005F5B6`, which represents 390,582 satoshi.

To be honest, I have a basic general understanding of big-endian vs little-endian but why is the little-endian format used? And why not just use the normal hex string format like `0005F5B6` in the example above?

**Tags:** raw-transaction, output, endianness

> **Comments:**
> **username_1**: Does this answer your question? [Why does the Bitcoin protocol use the little-endian notation?](https://bitcoin.stackexchange.com/questions/2063/why-does-the-bitcoin-protocol-use-the-little-endian-notation)  
> **username_0**: The replies on this thread and from the link you sent me both give me a better understanding of it. And it does seem like it has more to deal with lower level programming which I am not an expert in. Nonetheless, good education for myself.  

---

## 4 answers

### Answer by username_2 on 2023-05-23. Score: 5

To add onto username_3's answer, little endianness is a result of using little endian CPUs, and then sending data as it is stored in memory.

On little endian architectures, integers in memory are stored as little endian. When preparing messages to be sent over the network, Satoshi's serialization functions would simply copy the memory directly, thus inheriting the way that such data is stored in memory.

I believe the only exception to this is the uint256 implementation which is used for storing all 256 bit hashes. This appears to be deliberately written to interpret these integers as little endian.

Otherwise, the 0.1.0 client was written in a way that would not have been compatible with big endian architectures. If it were compiled for and ran on a big endian CPU, I think it would incorrectly deserialize integers. However the endianness used in the vast majority of computers is little endian, so this was unlikely to have caused an issue, not to mention that Windows isn't available on any big endian architectures anyways.


---

### Answer by username_3 on 2023-05-23. Score: 4

It is probably because Satoshi Nakamoto was sometimes rather careless.

It is a deviation from established standards that I would say has no sufficiently good reason in this particular case.

Just as interoperability among different Bitcoin node implementations is guided by Bitcoin Improvement Proposals (BIPs), interoperability among computers on the internet is guided by a system of Requests For Comments (RFCs). It seems likely that the BIP process was loosely modeled on the earlier RFC process.

RFC1700 by Reynolds and Postel in 1994 says

> When a multi-octet quantity is transmitted the most significant octet is
> transmitted first.

That is to say that "Network Order" is big-endian.

Computer hardware (the CPU etc) can be little-endian or big-endian. An application running on a little-endian machine is expected to translate to and from big-endian when communicating over the Internet. networking libraries provide for this. Most network protocols and applications do this.

Satashi Nakamoto failed to do this properly.

> **Comments:**
> **username_3**: I should probably add that clumsy mortal imperfect heroes are still heroes.  
> **username_4**: There is a very obvious good reason. Byte order conversions take time and the vast majority of computers impelementing this protocol are little-endian.  

---

### Answer by username_5 on 2023-05-23. Score: 2

There isn't any other reason for use of little-endian format than just the agreement made among programmers who implemented it. Bitcoin would have worked equally well with big-endian format.


---

### Answer by username_6 on 2023-05-23. Score: 1

As far as I know Satoshi never explained why both big endian and little endian are used in the Bitcoin protocol. Some of the reasons for using little endian generally are discussed [here](https://softwareengineering.stackexchange.com/questions/95556/what-is-the-advantage-of-little-endian-format) but I don't know to what extent they apply to its usage in Bitcoin.


---

