Python – cmath.inf 常量
cMath 模块包含许多用于复数数学运算的函数。 cmath.inf常量用于获得浮点正无穷大。
Syntax: cmath.inf
Returns: Return the value of positive infinity
下面的例子说明了上述函数的使用:
示例 #1:
Python3
# Python code to implement
# the cmath.inf constant
# importing "cmath"
# for mathematical operations
import cmath
# Print the positive infinity
val = cmath.inf
print(val)
Python3
# Python code to implement
# the cmath.inf constant
# importing "cmath"
# for mathematical operations
import cmath
# Print the negative infinity
val = -cmath.inf
print(val)
输出:
inf
示例 2:
Python3
# Python code to implement
# the cmath.inf constant
# importing "cmath"
# for mathematical operations
import cmath
# Print the negative infinity
val = -cmath.inf
print(val)
输出:
-inf