Question

I read on en.Wikipedia that "Big-endian systems store the most significant byte of a word at the smallest memory address and the least significant byte at the largest. A little-endian system, in contrast, stores the least-significant byte at the smallest address."
But I don't know what is "the smallest memory address", and how does "Big-endianness is the dominant ordering in networking protocols, such as in the internet protocol suite, where it is referred to as network order, transmitting the most significant byte first", in those type of protocols, the first is accessed the smallest memory address and in little-endian system is accessed the memory address?

Was it helpful?

Solution

If the map of memory bytes were arranged from left to right in incremental address order, the smallest address is on the left. The largest address is on the right.

Let's say you are storing the 32-bit value, 19088743, which is 0x01234567 in hex, at address 0x1000. Hence, the 4-byte value will span over the 4 bytes at memory address 0x1000, 0x1001, 0x1002, and 0x1003

In big endian, the 01 is stored at 0x1000 (the smallest address) and the 67 is stored at 0x1003 (the largest address). Exactly how you would think of it if you had never heard of little endian.

In little endian, the 01 is stored at 0x1003 (the largest address) and the 67 is stored at 0x01000 (the smallest address).

Big Endian and Network Byte Order generally mean the same thing.

Big Endian

|===================================|
| 0x1000 | 0x1001 | 0x1002 | 0x1003 |
|-----------------------------------|
|  0x01  |  0x23  |  0x45  |  0x67  |
|===================================|

Little Endian

|===================================|
| 0x1000 | 0x1001 | 0x1002 | 0x1003 |
|-----------------------------------|
|  0x67  |  0x45  |  0x23  |  0x01  |
|===================================|

OTHER TIPS

Say you have a computer with one GiB of memory, that is with $2^{30}$ bytes. You will have some mental image how this memory is arranged, from left to right, from right to left (People who are used to writing from left to right usually don’t do that), from top to bottom, or from bottom to top. That’s purely in your mind (or a drawing on paper), but whatever mental image you have, there’s a first and a last byte.

Usually you have a mapping from integer to memory bytes. In that case, you would likely associate the lowest number wit the first byte. Note that the lowest number is often not 0.

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top