c++ division by 0

前端 未结 5 1977
-上瘾入骨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:01

    Depends if you are using integers or floating points numbers. For integer, you'll get a runtime exception. For floating point numbers, the result will be +/- infinity, or NaN for (0.0/0.0), which you can test using std::isnan().

提交回复
热议问题