What do these three special floating-point values mean: positive infinity, negative infinity, NaN?

后端 未结 6 623
无人及你
无人及你 2020-12-31 12:22

How can we use them in our codes, and what will cause NaN(not a number)?

6条回答
  •  自闭症患者
    2020-12-31 12:35

    • 1/0 will result in positive infinity.
    • 0/0 will result in Nan. You can use NaN as any other number, eg: NaN+NaN=NaN, NaN+2.0=NaN
    • -1/0 will result in negative infinity.

    Infinity (in java) means that the result of an operation will be such an extremely large positive or negative number that it cannot be represented normally.

提交回复
热议问题