为什么无穷大 × 0 = NaN? [英] Why is Infinity × 0 = NaN?

查看:47
本文介绍了为什么无穷大 × 0 = NaN?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

IEEE 754 将 1/0 的结果指定为 ∞(无穷大).

IEEE 754 specifies the result of 1 / 0 as ∞ (Infinity).

但是,IEEE 754 然后将 0 × ∞ 的结果指定为 NaN.

However, IEEE 754 then specifies the result of 0 × ∞ as NaN.

这感觉反直觉:为什么 0 × ∞ 不是 0?

This feels counter-intuitive: Why is 0 × ∞ not 0?

  1. 我们可以将 1/0 = ∞ 视为 1/z 的极限,因为 z 趋于零

  1. We can think of 1 / 0 = ∞ as the limit of 1 / z as z tends to zero

我们可以认为 0 × ∞ = 0 是 0 × z 的极限,因为 z 趋于 ∞.

We can think of 0 × ∞ = 0 as the limit of 0 × z as z tends to ∞.

为什么 IEEE 标准遵循直觉 1. 而不是 2.?

Why does the IEEE standard follow intuition 1. but not 2.?

推荐答案

如果您不认为 IEEE 754 浮点零和无穷大的行为实际上是零或无穷大,则更容易理解它们.

It is easier to understand the behavior of IEEE 754 floating point zeros and infinities if you do not think of them as being literally zero or infinite.

浮点零不仅代表实数零.它们还代表所有会舍入到小于最小次正规数的实数.这就是为什么签名为零的原因.如果它们实际上不是零,即使很小的数字也有符号.

The floating point zeros not only represent the real number zero. They also represent all real numbers that would round to something smaller than the smallest subnormal. That is why zero is signed. Even tiny numbers do have a sign if they are not actually zero.

同样,每个无穷大也代表所有具有相应符号的数字,这些数字会四舍五入到某个大小不适合有限范围的数字.

Similarly, each infinity also represents all numbers with the corresponding sign that would round to something with a magnitude that would not fit in the finite range.

NaN 表示没有实数结果",例如 sqrt(-1),或没有线索".

NaN represents either "No real number result", for example sqrt(-1), or "Haven't a clue".

非常大的东西除以非常小的东西是非常非常大的,所以`Infinity/0 == Infinity".

Something very big divided by something very small is very, very big, so `Infinity / 0 == Infinity".

非常大的东西乘以非常小的东西可能是任何东西,这取决于我们不知道的实际大小.由于结果可能是从非常小到非常大的任何值,NaN 是最合理的答案.

Something very big multiplied by something very small could be anything, depending on the actual magnitudes that we don't know. Since the result could be anything from very small through very big, NaN is the most reasonable answer.

===================================================================

=================================================================

虽然我认为以上是理解实际浮点行为的最佳方式,但在实数限制中也会出现类似的问题.

Although I think the above is the best way to understand practical floating point behavior, a similar issue arises in real number limits.

假设 f(x) 趋于无穷,而 g(x) 趋于零,因为 x 趋于无穷.很容易证明 f(x)/g(x) 趋于无穷,正如 x 趋于无穷.另一方面,如果没有更多关于函数的信息,就无法证明 f(x)*g(x) 的极限.

Suppose f(x) tends to infinity and g(x) tends to zero as x tends to infinity. It is easy to prove that f(x)/g(x) tends to infinity as x tends to infinity. On the other hand, it is not possible to prove anything about the limit of f(x)*g(x) without more information about the functions.

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

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