Python math.isinf()- Methode
Beispiel
Überprüfen Sie, ob ein Wert unendlich ist oder nicht:
# Import math Library
import math
# Check whether the values are
infinite or not
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))
Definition und Verwendung
Die math.isinf()
Methode prüft, ob eine Zahl unendlich ist oder nicht.
Diese Methode gibt True zurück, wenn die angegebene Zahl eine positive oder negative Unendlichkeit ist, andernfalls gibt sie False zurück.
Syntax
math.isinf(x)
Parameterwerte
Parameter | Description |
---|---|
x | Required. The number to check |
Technische Details
Rückgabewert: | Ein bool Wert, True, wenn x eine positive oder negative Unendlichkeit ist, andernfalls False |
---|---|
Python-Version: | 2.6 |