Python math.inf Constant

Python math 模块Python math Module

Python math.infPositive infinity floating-point number, negative infinity, usage-math.inf 。

math.infEquivalent tofloat('inf')the output of.

Syntax

The math.inf constant syntax is as follows:

math.inf

Return Value

Returns a floating-point number representing positive infinity.

Example

The following example returns positive infinity and negative infinity:

Example

# Import math package
import math

# Output positive infinity
print (math.inf)

# Output negative infinity
print (-math.inf)

Output result:

inf
-inf

Python math 模块Python math Module

Other Extensions