c++ division by 0

前端 未结 5 1975
-上瘾入骨i
-上瘾入骨i 2020-11-29 08:28

I am running long simulations. I record the results into a vector to compute statistics about the data. I realized that, in theory, those samples could be the result of a di

5条回答
  •  离开以前
    2020-11-29 09:03

    For IEEE floats, division of a finite nonzero float by 0 is well-defined and results in +infinity (if the value was >zero) or -infinity (if the value was less than zero). The result of 0.0/0.0 is NaN. If you use integers, the behaviour is undefined.

提交回复
热议问题