I'm just curious, why in IEEE-754
any non zero float number divided by zero results in infinite value? It's a nonsense from the mathematical perspective. So I think that correct result for this operation is NaN.
Function f(x) = 1/x is not defined when x=0, if x is a real number. For example, function sqrt is not defined for any negative number and sqrt(-1.0f) if IEEE-754
produces a NaN
value. But 1.0f/0 is Inf
.
But for some reason this is not the case in IEEE-754
. There must be a reason for this, maybe some optimization or compatibility reasons.
So what's the point?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…