Python math.isinf() Method
Example
Check whether a value is infinity or not:
# Import math Library
import math
# Check whether some values are
infinite
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))
Try it Yourself »
Definition and Usage
The math.isinf()
method checks whether a value is
positive or negative infinity, or not. This method returns a Boolean value: True
if the value is
infinity, otherwise False
.
Syntax
math.isinf(x)
Parameter Values
Parameter | Description |
---|---|
x | Required. The value to check for infinity |
Technical Details
Return Value: | A bool value, True if the value is
infinity, otherwise False |
---|---|
Python Version: | 2.6 |