问题
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?
回答1:
Mathematically, 0/0 is indeterminate, and 0/anything_else is zero. IEEE-754 works the same way.
So 0/infinity will yield a zero. 0/0 will yield a NaN.
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.
来源:https://stackoverflow.com/questions/29426734/is-0-divided-by-infinity-guaranteed-to-be-0