简体   繁体   English

64位值的Endian表示

[英]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): (我只能验证第一个):

  • On a 32-bit little-endian processor, it will appear in memory as 67 45 23 01 EF CD AB 89 . 在32位小端处理器上,它将在内存中显示为67 45 23 01 EF CD AB 89
  • On a 64-bit little-endian processor, it will appear in memory as EF CD AB 89 67 45 23 01 . 在64位小端处理器上,它将作为EF CD AB 89 67 45 23 01出现在内存中。
  • On a 32-bit big-endian processor, it will appear in memory as 01 23 45 67 89 AB CD EF . 在32位大端处理器上,它将在内存中显示为01 23 45 67 89 AB CD EF
  • On a 64-bit big-endian processor, it will appear in memory as 01 23 45 67 89 AB CD EF . 在64位大端处理器上,它将在内存中显示为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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM