math.inf常数,带Python示例
Pythonmath.inf不变
math.inf常数是在math模块中定义的预定义常数,它返回浮点正无穷大(等于float('inf'))。
-math.inf可用于查找浮点负无穷大(等效于float('-inf'))。
注意:math.inf常数可从Python3.5获得
它的语法math.inf不变:
math.inf
返回值:float-这是正无穷大的值。
示例
Input:
print(math.inf)
Output:
infPython代码演示示例math.inf不变
#python代码演示示例
#math.infconstant
#导入数学模块
import math
#无限打印值
print("value of positive infinity = ", math.inf)
print("value of negative infinity = ", -math.inf)输出结果
value of positive infinity = inf value of negative infinity = -inf