CKTIS / Python
math.nan
Fournit la valeur flottante spéciale signalant l’absence de résultat numérique.
Version : Python 3.14; repository image, production runtime not attested
Syntaxe
math.nanFournit la valeur flottante spéciale signalant l’absence de résultat numérique.
Même math.nan comparé à lui-même par == donne False.
Pour filtrer des mesures, math.isnan donne True pour NaN et False pour l’infini.
import math
assert isinstance(math.nan, float) and math.nan != math.nan
assert math.isnan(math.nan) and not math.isinf(math.nan)
Exemples
import math
print(math.nan == math.nan)
print(math.isnan(math.nan))
Résultat
False True
Pour filtrer des mesures, math.isnan donne True pour NaN et False pour l’infini.