Easy Tutorial
❮ Ref Math Acosh Python With ❯

Python math.isinf() Method

Python math Module

The math.isinf() method in Python checks if x is an infinity value. It returns True if x is positive or negative infinity; otherwise, it returns False.

Python Version: 2.6

Syntax

The syntax for the math.isinf() method is as follows:

math.isinf(x)

Parameter Description:

Return Value

It returns a Boolean value. True if x is positive or negative infinity, otherwise False.

Example

The following example checks if a number is infinity:

# Import math package
import math

# Check if the number is infinity
print(math.isinf(56))
print(math.isinf(-45.34))
print(math.isinf(+45.34))
print(math.isinf(math.inf))
print(math.isinf(float("nan")))
print(math.isinf(float("inf")))
print(math.isinf(float("-inf")))
print(math.isinf(-math.inf))

Output result:

False
False
False
True
False
True
True
True

Python math Module

❮ Ref Math Acosh Python With ❯