字节序,“最重要”和“最不重要” [英] Endianness, "Most Significant", and "Least Significant"

查看:67
本文介绍了字节序,“最重要”和“最不重要”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在线阅读了有关大小尾数的说明。但是,它们似乎基本上都以相同的方式读取,并且我仍然对最大和最小有效字节的实际实现感到困惑。我知道小字节序值首先评估最低有效值,而在字节序大时,首先评估最高有效字节。但是,我不清楚最重要和最不重要的含义。我认为这将有助于我理解是否使用我将在此处提出的实际示例:

I've read descriptions online describing big and little endian. However, they all seem to basically read the same way and I am still confused on the the actual implementation regarding "most" and "least" significant bytes. I understand that little endian values evaluate the "least significant" values first and under big endian the "most significant" bytes are evaluated first. However, I'm unclear as to the meaning of "most" and "least" significant. I think it would help me to understand if I use an actual example which I will put forth here:

我有一个整数:12345

I have an integer value: 12345

如果使用Windows计算器将其转换为十六进制值,则会得到以下值:3039
(基本上是两个字节的值)。表示整数值12345的字节的值3039是否存储为小端或大端值,我如何根据该值确定该值?

If I convert it to a hex value using the Windows calculator, I get a value of: 3039 (basically a two byte value). Is the value 3039 showing the bytes representing the integer value 12345 stored as a little or big endian value and how do I determine this based on the value?

推荐答案

Endian-ness表示数字如何存储在内存中。它与字节的评估顺序无关。如果该页面上的内存地址从左到右增加,则将在大端存储的计算机上存储您的号码

Endian-ness refers to how numbers are stored in memory. It has nothing to do with evaluation order of bytes. If memory addresses increase left to right across this page, then on a big-endian machine your number would be stored

30 39

并在小端机上

39 30

您的计算器始终会即使我们将数字以小字节序的方式存储在您可能使用的英特尔硬件上,我们在阅读它们时也会显示数字,这是大字节序的方式。

Your calculator is always going to display numbers as we read them, which is the big-endian way, even though numbers are stored in little-endian fashion on the Intel hardware you're probably using.

这篇关于字节序,“最重要”和“最不重要”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆