简体   繁体   English

我的IEEE 754浮点表示法怎么了?

[英]What is wrong with my IEEE 754 floating point representation?

I am being asked in a homework to represent the decimal 0.1 in IEEE 754 representation. 我被要求在作业中以IEEE 754表示形式代表十进制0.1。 Here are the steps I made: 这是我执行的步骤:

在此处输入图片说明

However online converters, and this answer on stack exchange suggests otherwise. 但是,在线转换器以及堆栈交换上的答案则相反。 They put this solution: 他们提出了以下解决方案:

s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm
0 01111011 10011001100110011001101

The difference is the number 1 at the right. 区别是右边的数字1。 Why isn't it 1100, why is it 1101? 为什么不是1100,为什么不是1101?

As njuffa said in a comment, rounding is the explanation for the difference you see. 正如njuffa在评论中所说,四舍五入是您所看到的差异的解释。 Converters usually produce the nearest floating-point value to the decimal number you put in. The IEEE 754 standard recommends that the rounding mode be taken into account for conversions from one base to another (such as from decimal to binary), and the default rounding mode is “to nearest”. 转换器通常会产生与您输入的十进制数最接近的浮点值。IEEE 754标准建议将舍入模式考虑在内,以便从一个基数转换为另一个基数(例如,从十进制转换为二进制),并使用默认的舍入模式是“最接近”。

The two closest single-precision floating-point values to 1/10 are 1.10011001100110011001100×2 -4 and 1.10011001100110011001101×2 -4 (below and above 1/10). 接近1/10的两个最接近的单精度浮点值是1.10011001100110011001100×2 -4和1.10011001100110011001101×2 -4 (在1/10以下)。 The digits that are cut off are “11001100…”, indicating that the real 1/10 is closer to the upper bound than to the lower bound(if the remaining digits had been “100000000…”, the real number would have been exactly in-between the two). 截断的数字为“ 11001100…”,表示实数1/10比下限更接近上限(如果其余数字为“ 100000000…”,则实数应精确位于-两者之间)。 For this reason, the upper value 1.10011001100110011001101×2 -4 is chosen as the conversion of 1/10 to binary32 when converting in round-to-nearest mode. 因此,在以舍入至最近模式转换时,将上限值1.10011001100110011001101×2 -4选择为1/10转换为binary32。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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