Python math.isinf() Metodo
Esempio
Controlla se un valore è infinito o meno:
# 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))
Definizione e utilizzo
Il math.isinf()
metodo controlla se un numero è infinito o meno.
Questo metodo restituisce True se il numero specificato è un infinito positivo o negativo, altrimenti restituisce False.
Sintassi
math.isinf(x)
Valori dei parametri
Parameter | Description |
---|---|
x | Required. The number to check |
Dettagli tecnici
Valore di ritorno: | Un bool valore, Vero se x è un infinito positivo o negativo, Falso in caso contrario |
---|---|
Versione Python: | 2.6 |