<p>See <a href="https://en.wikipedia.org/wiki/Endianness" rel="nofollow noreferrer">little-endian and big-endian</a>.</p>
<p>The choice made by Bitcoin authors for data transmitted over the network is somewhat arbitrary. I think the reference implementation (Bitcoin core) chooses to store the data on disk verbatim as received from the network.</p>
<p>The standard for the Internet is called network order and is big-endian. The Intel x86 family of processors are little endian. The early software developers of Bitcoin didn't convert native order to network order when constructing packets. At least, not entirely.</p>

CC BY-SA 4.0
2021-04-21T15:53:37.757Z
2021-04-21T15:53:37.757Z
RedGrittyBrick
<p>I'm parsing the binary data from the bitcoin core blockchain blkxxxxx.dat files.
If I read out the magic number I get this:</p>
<blockquote>
<p>\xf9\xbe\xb4\xd9\</p>
</blockquote>
<p>Why isn't it stored the other way around, as the magic number is d9b4bef9? Is this just the way bytes are stored in memory?</p>
<p>I'm aware this is a complete noob question, but could anybody help me understand this. Thanks.</p>

<bitcoin-core><blockchain><raw-data><memory><chainanalysis>
Why is data stored in reverse in the blockchain files?
Bitcoingraffiti
# Why is data stored in reverse in the blockchain files?

(Asked by: username_0 on 2021-04-21)

I'm parsing the binary data from the bitcoin core blockchain blkxxxxx.dat files.
If I read out the magic number I get this:

> \xf9\xbe\xb4\xd9\

Why isn't it stored the other way around, as the magic number is d9b4bef9? Is this just the way bytes are stored in memory?

I'm aware this is a complete noob question, but could anybody help me understand this. Thanks.

**Tags:** bitcoin-core, blockchain, raw-data, memory, chainanalysis


---

## 1 answers

### Answer by username_1 on 2021-04-21. Score: 2 | Accepted answer

See [little-endian and big-endian](https://en.wikipedia.org/wiki/Endianness).

The choice made by Bitcoin authors for data transmitted over the network is somewhat arbitrary. I think the reference implementation (Bitcoin core) chooses to store the data on disk verbatim as received from the network.

The standard for the Internet is called network order and is big-endian. The Intel x86 family of processors are little endian. The early software developers of Bitcoin didn't convert native order to network order when constructing packets. At least, not entirely.


---

