What is inf and nan?

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

    You say:

    when i do nan - inf i dont get -inf i get nan

    This is because any operation containing NaN as an operand would return NaN.

    A comparison with NaN would return an unordered result.

    >>> float('Inf') == float('Inf')
    True
    >>> float('NaN') == float('NaN')
    False
    

提交回复
热议问题