Python math.inf常数 (Python math.inf constant)
math.inf constant is a predefined constant, which is defined in the math module, it returns a floating-point positive infinity (which is equivalent to float('inf')).
math.inf常量是在math模块中定义的预定义常量,它返回浮点正无穷大(等效于float('inf')) 。
-math.inf can be used to find floating-point negative infinity (which is equivalent to float('-inf')).
-math.inf可用于找到浮点负无穷大(等效于float('-inf')) 。
Note: math.inf constant is available from Python 3.5
注意: math.inf常数可从Python 3.5获得
Syntax of math.inf constant:
math.inf常数的语法:
math.inf
Return value: float – that is the value of positive infinity.
返回值: float-这是正无穷大的值。
Example:
例:
Input:
print(math.inf)
Output:
inf
Python代码演示math.inf常量示例 (Python code to demonstrate example of math.inf constant)
# python code to demonstrate example of
# math.inf constant
# importing math module
import math
# printing value of infinity
print("value of positive infinity = ", math.inf)
print("value of negative infinity = ", -math.inf)
Output
输出量
value of positive infinity = inf
value of negative infinity = -inf
Recommended posts
推荐的帖子
Reference: Python math library
参考: Python数学库
翻译自: https://www.includehelp.com/python/math-inf-constant-with-example.aspx