Wed. Jun 12th, 2024

[ad_1]

What is the default endianness of the arith_uint256 type?

tl;dr: The one chosen by the libraries and compiler you are using for the processor you targeted? But that’s not what you need to know.


Endianness is a greater source of confusion in Bitcoin than in any other software project I have encountered.

CPU

Some historically popular processors, 68K, SPARC, PowerPC, were big-endian – but these are no longer significant.

Currently, most personal computers that are larger than pocket sized use processors that are little-endian. Most of those processors have an instruction to efficiently swap between byte orders. For example bswap or rev. This sort of provision normally makes endianness relatively unimportant for efficiency considerations.

Current ARM processor designs are said to be bi-endian. They can work with either endianness with equal efficiency.

Internet

Internet standards specify that data transmitted over the Internet should transmit numbers in big-endian order. However Bitcoin does not. This also is a source of confusion.

Software

In most of the software development projects I have worked on, including heterogeneous network applications, endianness is not an issue. Developers don’t even need to be aware of endianness. The compiler takes care of this for you. Standard software libraries take care of this for you.

Bitcoin core is an exception to this. There are probably many others but it is the only project I recall encountering where this is a big issue that frequently trips people up and causes confusion so often.

Humans

Most numbers presented to humans in hexadecimal notation are presented as big-endian. This means the most significant digits are on the left, so that in a left-to-right writing system the offset or position-index is smallest for the most significant digit.


Conclusion

The order you see in a hexadecimal representation might have been ordered to suit human interpretation or it might be ordered to match, for example, network order. Context should make this apparent.


[ad_2]

Source link

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *