Méthode Python math.isinf()
Exemple
Vérifiez si une valeur est infinie ou non :
# 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))
Définition et utilisation
La math.isinf()
méthode vérifie si un nombre est infini ou non.
Cette méthode renvoie True si le nombre spécifié est un infini positif ou négatif, sinon elle renvoie False.
Syntaxe
math.isinf(x)
Valeurs des paramètres
Parameter | Description |
---|---|
x | Required. The number to check |
Détails techniques
Valeur de retour : | Une bool valeur, True si x est un infini positif ou négatif, False sinon |
---|---|
Version Python : | 2.6 |