The cmath.isfinite()
function returns a boolean value indicating whether the input complex number is a finite number or not.
In Python some complex values which are not finite includes Infinity, represented as complex('inf')
and NaN(Not a Number) represented as complex('nan')
and any operations involving them.
cmath.isfinite(x)
x |
The value(real) or complex whose value should be checked for finiteness. |
The function returns True
if both the real and imaginary parts of x
are finite, else False
.
import cmath
print(cmath.isfinite(1 + 2j))
print(cmath.isfinite(11 + 7j))
print(cmath.isfinite(complex('inf')))
print(cmath.isfinite(complex('nan')))
print(cmath.isfinite(complex('-inf')))
print(cmath.isfinite(cmath.inf + 2j))