math.inf常数,带Python示例

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

推荐的帖子

  • math.isfinite() method with example in Python

    带有Python示例的math.isfinite()方法

  • math.isinf() method with example in Python

    带有Python示例的math.isinf()方法

  • math.isnan() method with example in Python

    带有Python示例的math.isnan()方法

  • math.remainder() method with example in Python

    带有Python示例的math.remainder()方法

  • math.ceil() method with example in Python

    Python中带有示例的math.ceil()方法

  • math.floor() method with example in Python

    带有Python示例的math.floor()方法

  • math.exp() method with example in Python

    带有Python示例的math.exp()方法

  • math.fabs() method with example in Python

    带有Python示例的math.fabs()方法

  • math.fmod() method with example in Python

    带有Python示例的math.fmod()方法

  • math.modf() method with example in Python

    带有Python示例的math.modf()方法

  • math.fsum() method with example in Python

    带有Python示例的math.fsum()方法

  • math.gcd() method with example in Python

    带有Python示例的math.gcd()方法

  • math.pow() method with example in Python

    带有Python示例的math.pow()方法

  • math.sqrt() method with example in Python

    带有Python示例的math.sqrt()方法

  • math.factorial() method with example in Python

    带有Python示例的math.factorial()方法

Reference: Python math library

参考: Python数学库

翻译自: https://www.includehelp.com/python/math-inf-constant-with-example.aspx

你可能感兴趣的:(math.inf常数,带Python示例)