What is the point of float('inf') in Python?

后端 未结 5 1799
滥情空心
滥情空心 2020-12-02 16:26

Just wondering over here, what is the point of having a variable store an infinite value in a program? Is there any actual use and is there any case where it would be prefer

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 16:57

    From the documentation:

    Many floating-point features were added. The float() function will now turn the string nan into an IEEE 754 Not A Number value, and +inf and -inf into positive or negative infinity. This works on any platform with IEEE 754 semantics. (Contributed by Christian Heimes; issue 1635.)

    Also refer this: Working with Infinity and NaNs

提交回复
热议问题