Like this case:
0x01234567,
When it's in big endian machine ,
it was saved as [01][23][45][67].That's clear and understanderable;
But when it's in little endian machine ,
it was saved as [67][45][23][01].That's the thing casusing my confusion.
Why it's not saved as [76][54][32][10]?
At first , I thought it's about bit ordering(or bit numbering).But I don't know it exactly.So that's my question. Why ?
Sorry for my English if it gives you some trouble.
Asked
Active
Viewed 150 times
0

Seight
- 11
-
Endianness is typically used to refer to how bytes are ordered in multi-byte values; `0x67` is one byte. It would never change to `0x76` because that would imply the endianness is being applied to groups of 4 bits, which would be very unusual. Even if we used endianness to refer to how bits are ordered inside a byte, reversing the endianness of `0x67` (`01100111`) would result in `0x73` (`11100110`). – Jeroen Mostert May 09 '21 at 15:24
-
Well, make that `0xe6` rather than `0x73`, obviously, I can't into binary today. – Jeroen Mostert May 09 '21 at 15:37
-
@JeroenMostert: you just shifted the result right by one bit, so an off-by-one kind of thing. Perfectly normal on a Sunday if you haven't had enough coffee. :-) – Bob Jarvis - Слава Україні May 09 '21 at 15:41
1 Answers
0
"Little-endian" architectures I'm familiar with do not alter the order of the bits within a byte when they store a value. In this case it seems you're expecting the processor to reverse the order of the nibbles within each byte when they're stored, and then reverse them again when they're fetched, but this is not done by any processor I'm familiar with. Perhaps you could design a processor which stores 0x01234567 as [E6][A2][B4][80], i.e. by reversing the bit order of the bits within each byte, and then reverses the bit order again when loading such values. Implementation is left as an exercise for the motivated reader.

Bob Jarvis - Слава Україні
- 48,992
- 9
- 77
- 110