Python - Methode cmath.isinf()
Beispiel
Prüfen Sie, ob ein komplexer Wert unendlich ist oder nicht:
#import cmath for complex number operations
import cmath
#find
whether a complex number is infinite or not
print (cmath.isinf(complex(10
+ float('inf'))))
print (cmath.isinf(11 + 4j))
Definition und Verwendung
Die cmath.isinf()
Methode prüft, ob ein Wert positiv oder negativ unendlich ist oder nicht. Diese Methode gibt einen booleschen Wert zurück: True
wenn der Wert unendlich ist, andernfalls False
.
Syntax
cmath.isinf(x)
Parameterwerte
Parameter | Description |
---|---|
x | Required. The value to check for infinity |
Technische Details
Rückgabewert: | Ein bool Wert, True wenn der Wert unendlich ist, andernfallsFalse |
---|---|
Python-Version: | 2.6 |