test for nan
Roel Schroeven
rschroev_nospam_ml at fastmail.fm
Wed Mar 31 14:27:25 EST 2004
Skip Montanaro wrote:
> John> Is there a better way to test for NaN than
>
> John> str(p1)=='nan'
>
> John> where p1 is a float?
>
> Saw this in the list archives earlier today:
>
> >>> inf = float("1e9999")
> >>> inf
> Inf
> >>> nan = inf-inf
> >>> nan
> NaN
> >>> p1 = 5.0
> >>> p1 == nan
> False
>>> a = inf-inf
>>> a == nan
False
Seems to return False always, that doesn't really help...
--
"Codito ergo sum"
Roel Schroeven
More information about the Python-list
mailing list