I would recommend proving this for yourself. However counter-intuitive it might seem at first, there are valid reasons why little-endian is used over big-endian. The reason for the widespread use of little-endian is not because of the ease of user understanding as you might have figured out , but rather for ease of the computer. We will use this 8-byte value 0x When we store it in little-endian we have the following.
We are doing something called a pointer down cast. We will say they both point to 0x When we run this, we will get two very different results depending on what endianness the processor uses. This is because when we re-interpret the memory in 4-byte chunks and get the following:. Now, when we only grab 4 bytes at memory location 0x00 we get the 4 least significant bytes from the original 8-byte value.
Feel free to try this out on your computer. Big-endian, as you may expect, behaves very differently. Imagine that we ran this code on a big-endian processor instead. Design patterns. Documenting a Software Architecture. Comments Please enable JavaScript to view the comments powered by Disqus. Uy Nguyen Software engineer uynguyen. Posts Categories 0.
Tags Links Uy Nguyen uynguyen. Recent Silent notification. Tags BLE 6. Books 1. Cocoa 1. Concurrency 4. Conference 1. Once established, and for compatibility reasons, the endianness was more or less carried on to later generations of hardware; which would support the 'legacy' argument for why still both kinds exist today.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. The reason behind endianness? Ask Question. Asked 8 years, 11 months ago. Active 8 days ago. Viewed 12k times. Also I know that: The little-endian system has the property that the same value can be read from memory at different lengths without using different addresses.
Matthias Braun Valentin Radu Valentin Radu 8, 8 8 gold badges 58 58 silver badges 90 90 bronze badges. It appears you're quoting the Wikipedia article on Endianness.
The next paragraph states, "On the other hand, in some situations it may be useful to obtain an approximation of a multi-byte or multi-word value by reading only its most-significant portion instead of the complete representation; a big-endian processor may read such an approximation using the same base-address that would be used for the full value.
True, that must be one advantage in using big-endian, but, are these the only reasons for which the two exist? Add a comment. Active Oldest Votes. Patterns can be offset by arbitrary numbers of bits, and a repeating sequence can be recognized regardless of endianness.
Moreover, imagine we're comparing two same -sized integers; say, two pointers. It's probably interesting if those pointers have the same high bits, but it's completely irrelevant if just their low bits are the same. So in that case recognizing the high bits is more important. I don't know why, but I imagine nullplan's arguments probably cover it. There's another argument for little-endian, but it doesn't apply to many OSs: In arbitrary-precision calculations, adding or subtracting numbers needs to start with the low digits for the carry to propagate correctly.
Yes, even though you borrow in the other direction when doing subtraction longhand. I don't know about multiplication and division. In human language, big-endian makes rounding more natural.
0コメント