Home >>Python math Module >Python math.isinf() Method

Python math.isinf() Method

Python math.isinf() Method

Python math.isinf() method is used to check whether a given input value is positive or negative infinity, or not. It returns a Boolean value True if the value is infinity and False value if it is not.

Syntax:
math.isinf(x)

Parameter Values

Parameter Description
x This is a required parameter. It defines the value to check for infinity.
Here is an example of Python math.isinf() method:

import math
print (math.isinf (56))
print (math.isinf (-45.34))
print (math.isinf (float("nan")))
print (math.isinf (float("inf")))
print (math.isinf (math.inf))

Output:
False
False
False
True
True
Example 2:

import math
print (math.isinf (math.inf))
print (math.isinf (-math.inf))
print (math.isinf (float("nan")))
print (math.isinf (float("inf")))
print (math.isinf (float("-inf")))

Output:
True
True
False
True
True

No Sidebar ads