0除以无限是否保证为0? [英] Is 0 divided by infinity guaranteed to be 0?
本文介绍了0除以无限是否保证为0?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
根据此问题,对于n != 0
,n/inf
预期为零.何时n == 0
呢?根据IEEE-754,(0 / inf) == 0
始终是真的吗?
According to this question, n/inf
is expected to be zero for n != 0
. What about when n == 0
? According to IEEE-754, is (0 / inf) == 0
always true?
推荐答案
从数学上讲,0/0是不确定的,0/anything_else是零. IEEE-754的工作方式相同.
Mathematically, 0/0 is indeterminate, and 0/anything_else is zero. IEEE-754 works the same way.
因此0/无穷大将产生零. 0/0将产生NaN.
So 0/infinity will yield a zero. 0/0 will yield a NaN.
注意:并非所有的C ++实现都支持IEEE浮点,有些不完全符合IEEE规范,因此这不一定是C ++问题.
Note: not all C++ implementations support IEEE floating point, and some that do so don't completely meet IEEE specifications, so this is not necessarily a C++ question.
这篇关于0除以无限是否保证为0?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文