IEEE 754为什么保留这么多的NaN值? [英] Why does IEEE 754 reserve so many NaN values?

查看:186
本文介绍了IEEE 754为什么保留这么多的NaN值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来,IEEE 754标准定义了16,777,214个32位浮点值作为NaN,或0.4%的所有可能的值。

我想知道什么是理由为了保留这么多有用的价值,而只有2个基本上需要:一个用于信号和一个安静的钠。



对不起,如果这个问题是微不足道的,我找不到任何解释在互联网上。

解决方案

IEEE-754标准定义一个NaN作为指数中的所有1的数字,一个非零的有效数。有效位中的最高位指定NaN是信令还是安静。剩余的有效位形成了NaN的有效载荷



每当一个操作的操作数之一是NaN,结果是NaN,并且结果的有效载荷等于NaN操作数中的一个的有效载荷。有效负载保存对于,以及至少有一家公司已经提议使用NaN有效载荷作为专有用途。



在更基本的术语中,NaN没有携带任何有用的数字信息,并且无论如何必须保留整个32位,所以如果在标准中没有定义有效载荷,那么有效位中的未使用的位将会被浪费。


It seems that the IEEE 754 standard defines 16,777,214 32-bit floating point values as NaNs, or 0.4% of all possible values.

I wonder what is the rationale for reserving so many useful values, while only 2 ones essentially needed: one for signaling and one for quiet NaN.

Sorry if this question is trivial, I couldn't find any explanation on the internet.

解决方案

The IEEE-754 standard defines a NaN as a number with all ones in the exponent, and a non-zero significand. The highest-order bit in the significand specifies whether the NaN is a signaling or quiet one. The remaining bits of the significand form what is referred to as the payload of the NaN.

Whenever one of the operands of an operation is a NaN, the result is a NaN, and the payload of the result equals the payload of one of the NaN operands. Payload preservation is important for efficiency in scientific computing, and at least one company has proposed using NaN payloads for proprietary uses.

In more basic terms, a NaN doesn't carry any useful numerical information, and the entire 32 bits must be reserved anyway, so the unused bits in the significand would be otherwise wasted if there were not a payload defined in the standard.

这篇关于IEEE 754为什么保留这么多的NaN值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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