←back to thread

27 points andwati | 2 comments | | HN request time: 0.783s | source
Show context
MrBuddyCasino ◴[] No.45905428[source]
What first confused me about endianness is that it is about byte order, not bit order. The latter would have seemed more logical, or is this just me?
replies(5): >>45905811 #>>45906279 #>>45906495 #>>45907705 #>>45907834 #
1. andwati ◴[] No.45905811[source]
Learning this initially was confusing for me too, aren't we arranging bits?
replies(1): >>45907944 #
2. kazinator ◴[] No.45907944[source]
The words are divided into bytes. The bytes are rearranged, but the bits stay the same. The bits are not addressable and so represent pure binary values.

For instance given the word DEADBEEF, the least significant byte is EF.

That is a specific binary value: the value 239.

That value stays the same whether the bytes are EF BE AD DE in memory, or DE AD BE EF.

EF is just 239. We don't think about reversing the bits; they are not addressable. They have an abstract order determined by the binary system. The most significant bit of the value contributes 128 and so on.

The order matters when the bits have to be transmitted over a wire to another machine. Then we have to decide: do we transmit the low bit of EF first, or the high bit 1? If the two sides of the data link are inconsistent, then one side transmits 11101111 and the other receives 11110111, which is F7.