c++ division by 0

前端 未结 5 1994
-上瘾入骨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 08:56

    If you're talking integers then your program should crash upon division by zero.

    If you're talking floats then division by zero is allowed and the result to that is INF or -INF. Now it's all up to your code if the program will crash, handle that nicely or continue with undefined/unexpected results.

提交回复
热议问题