What is inf and nan?

前端 未结 5 722
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-28 11:57

Just a question that I\'m kind of confused about

So I was messing around with float(\'inf\') and kind of wondering what it is used for.

Also I n

5条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-28 12:51

    inf is infinity - a value that is greater than any other value. -inf is therefore smaller than any other value.

    nan stands for Not A Number, and this is not equal to 0.

    Although positive and negative infinity can be said to be symmetric about 0, the same can be said for any value n, meaning that the result of adding the two yields nan. This idea is discussed in this math.se question.

    Because nan is (literally) not a number, you can't do arithmetic with it, so the result of the second operation is also not a number (nan)

提交回复
热议问题