Python math.isinf() Method
Python math.isinf() The method determines whether x is infinite, returning True if x is positive or negative infinity, otherwise False.
Python version: 2.6
Syntax
The syntax of the math.isinf() method is as follows:
math.isinf(x)
Parameter Description:
- x -- required, a number. If x is not a number, a TypeError is returned.
Return Value
Returns a Boolean; True if x is positive or negative infinity, otherwise False.
Example
The following example checks whether numbers are infinite:
Example
Import the math package
import
math
Check whether a number is infinite
(
math
.
isinf
(
56
)
)
(
math
.
isinf
(
45.34
)
)
(
math
.
isinf
(
45.34
)
)
(
math
.
isinf
(
math
.
inf
)
)
(
math
.
isinf
(
float
(
"nan"
)
)
)
(
math
.
isinf
(
float
(
"inf"
)
)
)
(
math
.
isinf
(
float
(
"-inf"
)
)
)
(
math
.
isinf
(
math
.
inf
)
)
Output result:
False
False
False
True
False
True
True
True
Python math Module