Difference between Infinity and NaN (Not a number)

后端 未结 3 679
难免孤独
难免孤独 2020-12-20 23:58

When does java print Infinity and when does it print NaN?

Why is 1.0/0.0 infinity but ((1.0/0.0) - (1.0/0.0)) NaN and 0.0f/0.0f an NaN?

What is the differenc

3条回答
  •  既然无缘
    2020-12-21 00:24

    Because Java is following known math facts. 1.0 / 0.0 is infinity, but the others are indeterminate forms, which Java represents as NaN (not a number).

提交回复
热议问题