floating-point - 是否存在无效的浮点状态/值?

标签 floating-point ieee-754 low-level

我知道存在 NaN 和各种其他特殊情况。但是还有其他未使用的完全无效的二进制值吗?

例如,IEEE 754确实允许 -0。但如果没有,则二进制值 10000000000000000000000000000000 将无效。是否还有其他未处理的边缘情况?

最佳答案

IEEE-754 二进制和十进制交换格式没有任何未定义的位模式。 (对于十进制,IEEE 754-2008 第 3.5.2 条中的编码部分指定了所有位串的值 [包括 NaN“值”]。某些位串被指定为非规范的,但所有位串都有已定义的值。)

英特尔的“双扩展精度”格式确实具有未定义的位模式。 Intel 64 和 IA-32 架构软件开发人员手册,2017 年 12 月,8.2.2“不支持的 double 扩展精度浮点编码和伪非规范”说:

The double extended-precision floating-point format permits many encodings that do not fall into any of the categories shown in Table 4-3. Table 8-3 shows these unsupported encodings. Some of these encodings were supported by the Intel 287 math coprocessor; however, most of them are not supported by the Intel 387 math coprocessor and later IA-32 processors. These encodings are no longer supported due to changes made in the final version of IEEE Standard 754 that eliminated these encodings.

Specifically, the categories of encodings formerly known as pseudo-NaNs, pseudo-infinities, and un-normal numbers are not supported and should not be used as operand values. The Intel 387 math coprocessor and later IA-32 processors generate an invalid-operation exception when these encodings are encountered as operands.

表 8-3 显示未定义的模式在整数位(有效数的前导位,显式存储在 Intel 格式的专用“整数”一位字段中)和非零中都有一个零指数域。当指数字段全为 1 时,这些是伪 NaN(如果分数字段非零)或伪无穷大(如果分数字段为零)。当指数域既不是全 1(也不是全 0)时,这些都是非正态的。

(当整数位为零且指数字段全为零时,该数字是普通次正规数;零整数位正确匹配指数字段隐含的零。)

其他供应商和各方当然也可能有自己的格式,但未定义位模式。

关于floating-point - 是否存在无效的浮点状态/值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69974129/

相关文章:

c++ - IEEE 754 浮点除法的可逆性

javascript - 如何从 Javascript 中的符号、尾数和指数中获取小数

optimization - OpenGL ES 2.0 中元胞自动机的纹理格式

assembly - 使用 MASM 汇编器将华氏度转换为摄氏度

floating-point - 相对误差和摆动

python - 舍入Python中的错误

python - 关于 pandas.read_csv 的 float_precision 参数

c - Linux 内核 filp_open 失败并显示 NOENT

php获取小数点后的值

floating-point - 16 位、32 位和 64 位 IEEE-754 系统可以表示什么范围的数字?