Python math.isfinite() Metodo
Esempio
Controlla se un valore è finito o meno:
# Import math Library
import math
# Check whether the values are
finite or not
print(math.isfinite(2000))
print(math.isfinite(-45.34))
print(math.isfinite(+45.34))
print(math.isfinite(math.inf))
print(math.isfinite(float("nan")))
print(math.isfinite(float("inf")))
print(math.isfinite(float("-inf")))
print(math.isfinite(-math.inf))
print(math.isfinite(0.0))
Definizione e utilizzo
Il math.isfinite()
metodo controlla se un numero è finito o meno.
Questo metodo restituisce True se il numero specificato è un numero finito, altrimenti restituisce False.
Sintassi
math.isfinite(x)
Valori dei parametri
Parameter | Description |
---|---|
x | Required. The value to check. Must be a number (float/integer/infinite/NaN/finite) |
Dettagli tecnici
Valore di ritorno: | Un bool valore, Vero se x è finito, Falso se x è un infinito o un NaN |
---|---|
Versione Python: | Novità in Python 3.2 |