Why does division by zero in IEEE754 standard results in Infinite value?

后端 未结 4 2119
孤街浪徒
孤街浪徒 2020-11-27 15:51

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

4条回答
  •  猫巷女王i
    2020-11-27 16:16

    In mathematics, division by zero is undefined because zero has no sign, therefore two results are equally possible, and exclusive: negative infinity or positive infinity (but not both).

    In (most) computing, 0.0 has a sign. Therefore we know what direction we are approaching from, and what sign infinity would have. This is especially true when 0.0 represents a non-zero value too small to be expressed by the system, as it frequently the case.

    The only time NaN would be appropriate is if the system knows with certainty that the denominator is truly, exactly zero. And it can't unless there is a special way to designate that, which would add overhead.

提交回复
热议问题