大端序vs小端序

一、背景

大端序:big-endian

小端序:little-endian

这两个概念相信大家都不陌生,应该在面试中经常被问,大家都知道这是指多字节存储时的顺序,那么为什么一个叫大端序、一个叫小端序了?根据字面意义很难一下子说出来到底哪个对应哪个。

二、探究

这些概念的东西靠死记硬背是很难记住的,即使强行记住也容易临时记反,导致失误,其实这个词导致我们这么难理解的主要原因是翻译的有点词不达意,所以这里就来扒一扒该怎么更好的理解它。

这里直接摘抄一篇的文章内容,我任务解释的很清楚:

Endianness is a term that describes the order in which a sequence of bytes are stored in computer memory. Endianness can be either big or small, with the adjectives referring to which value is stored first.

Big endian vs. little endian
Big-endian is an order in which the "big end" (most significant value in the sequence) is stored first (at the lowest storage address). Little-endian is an order in which the "little end" (least significant value in the sequence) is stored first.

意思就是:

endianness是一个描述一列bytes存储在计算机内存中的顺序的术语。endianness可以是big或者small,big或者small指出了哪部分值先存储(从低位开始)。

所以,big-end就表示大的值先存储,little-end就表示小的值先存储。

例子:

 

 

三、总结

因此只需要记住big-end、little-end中的big和little是用来指定大值先存储还是小值先存储就好记了。

个人认为翻译成:大尾vs小尾更好理解,表示尾部(低地址)存储大指还是小值。

四、参考

1、https://chortle.ccsu.edu/AssemblyTutorial/Chapter-15/ass15_3.html

2、https://searchnetworking.techtarget.com/definition/big-endian-and-little-endian

posted @ 2020-05-22 14:02  冷冰若水  阅读(388)  评论(0编辑  收藏  举报