Why is number divided by zero infinity in Java?

后端 未结 5 1317
遥遥无期
遥遥无期 2020-12-04 00:00

Why should the following code in Java

System.out.println(new Integer(1)/ new Double(0));

print \'Infinity\' and not undefined. Isn\'t that

5条回答
  •  天涯浪人
    2020-12-04 00:59

    This is consistent with the IEEE 754 standard on floating-point, which Java follows.

提交回复
热议问题