[英]Endian representation of 64-bit values
Suppose I have unsigned long long x = 0x0123456789ABCDEF
. 假设我
unsigned long long x = 0x0123456789ABCDEF
。
Which of the following is correct? 以下哪项是正确的? (I can verify only the first one):
(我只能验证第一个):
67 45 23 01 EF CD AB 89
. 67 45 23 01 EF CD AB 89
。 EF CD AB 89 67 45 23 01
. EF CD AB 89 67 45 23 01
出现在内存中。 01 23 45 67 89 AB CD EF
. 01 23 45 67 89 AB CD EF
。 01 23 45 67 89 AB CD EF
. 01 23 45 67 89 AB CD EF
。 The first one is wrong. 第一个是错的。 On ia32 at least the layout is
EF CD AB 89 67 45 23 01
. 在ia32上,至少布局是
EF CD AB 89 67 45 23 01
。
The others are correct. 其他是正确的。
Little endian means the least-significant bits are in the first byte, and big endian means the least-significant bits are in the last byte: 小端表示最低有效位在第一个字节中,而大端表示最低有效位在最后一个字节中:
0x0123456789ABCDEF big endian is 0x01, 0x23, 0x45 ... 0x0123456789ABCDEF大端是0x01,0x23,0x45 ......
0x0123456789ABCDEF little endian is 0xEF, 0xCD, 0xAB ... 0x0123456789ABCDEF小端是0xEF,0xCD,0xAB ...
The native word endianess and size of the processor is inconsequential; 本机字的endianess和处理器的大小是无关紧要的; the appearance in memory is dictated by the endian.
记忆中的外观由端序决定。
I'd say the 32-bit solution is very much up to the compiler. 我要说32位解决方案非常适合编译器。 It can choose to represent this type that it lacks native support for in any way it pleases, as long as the size is the expected one.
只要大小是预期的,它就可以选择代表它缺乏本地支持的类型。
The 64-bit ones I'd agree with as being correct. 64位的我同意是正确的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.