comparing nan "number"
Michael Hudson
mwh at python.net
Mon Dec 1 14:00:22 EST 2003
jjl at pobox.com (John J. Lee) writes:
> Boštjan Jerko <bostjan.jerko at mf.uni-lj.si> writes:
>
> > I need to know if the result of math formula is nan (Not a number).
> > How can I do that?
>
> I suppose:
>
> NAN = any_calculation_that_returns_nan()
>
> if some_other_calculation() is NAN:
> ...
I wouldn't expect that to work. Unfortunately, I don't think there is
a reliable way.
result = some_calculation()
if result != result:
# it's a nan
*might* work, depending probably on compiler, Python version, platform
and phase of the moon.
Cheers,
mwh
--
There's a difference between random people with stripy jumpers,
and a respected scientist with a reputation.
-- Steve Kitson, ucam.chat
More information about the Python-list
mailing list