c++ division by 0

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

    If you use IEEE floats, then it will return 0 or NaN. If the op1 is 0, you will get undefined. If op1 is higher than 0, you will get Infinity. If op1 is lower than 0, then you will get -Infinity. If you use dividing by 0 directly or in integer , you will get error "Floating point exception".

提交回复
热议问题