在 IEEE-754 基本 32 位二进制浮点格式中,可以表示从 −16,777,216 到 +16,777,216 的所有整数。从 16,777,216 到 33,554,432,只能表示偶数。然后,从 33,554,432 到 67,108,864,只能表示四的倍数。 (由于这个问题不需要讨论哪些数字可以表示,因此我将省略解释并认为这是理所当然的。)
最常见的默认舍入模式是将精确的数学结果舍入到最接近的可表示值,并且在平局的情况下,舍入到其有效数的低位为零的可表示值。
16,777,217 is equidistant between the two representable values 16,777,216 and 16,777,218. These values are represented as 1000000000000000000000002•21 and 1000000000000000000000012•21. The former has 0 in the low bit of its significand, so it is chosen as the result.
16,777,219 is equidistant between the two representable values 16,777,218 and 16,777,220. These values are represented as 1000000000000000000000012•21 and 1000000000000000000000102•21. The latter has 0 in the low bit of its significand, so it is chosen as the result.