如何将此二进制数四舍五入到最接近的偶数

How do I round this binary number to the nearest even

我有 0.1 的二进制表示:

0.00011001100110011001100110011001100110011001100110011001100110

我需要将它四舍五入到最接近的值,以便能够将它存储在双精度浮点数中。我似乎无法理解该怎么做。大多数教程都在谈论保护位、圆形位和粘性位——它们在此表示中的什么位置?

我还找到了以下解释:

Let’s see what 0.1 looks like in double-precision. First, let’s write it in binary, truncated to 57 significant bits:

0.000110011001100110011001100110011001100110011001100110011001…

Bits 54 and beyond total to greater than half the value of bit position 53, so this rounds up to

0.0001100110011001100110011001100110011001100110011001101

这篇不讲GRS比特,为什么呢?他们不是总是需要的吗?

您引用的文字来自我的文章 Why 0.1 Does Not Exist In Floating-Point . In that article I am showing how to do the conversion by hand, and the "GRS" bits are an IEEE implementation detail. Even if you are using a computer to do the conversion, you don't have to use IEEE arithmetic (and you shouldn't if you want to do it correctly ),因此 GRS 位也不会在那里发挥作用。无论如何,GRS 位适用于计算,而不是真正适用于转换的概念。