What is inf and nan?

前端 未结 5 724
佛祖请我去吃肉
佛祖请我去吃肉 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:47

    Inf is infinity, it's a "bigger than all the other numbers" number. Try subtracting anything you want from it, it doesn't get any smaller. All numbers are < Inf. -Inf is similar, but smaller than everything.

    NaN means not-a-number. If you try to do a computation that just doesn't make sense, you get NaN. Inf - Inf is one such computation. Usually NaN is used to just mean that some data is missing.

提交回复
热议问题