Floats and NaNs
Dalton, Tom
tom.dalton at eds.com
Mon Dec 3 11:51:48 EST 2007
Hi,
Is there any way to detect if a float is NaN in Python 2.4?
I can pretty much understand why
float("nan") == float("nan") -> False
but I then expected there to be an isnan() function, perhaps provided by
the maths module. I understand a lot of the floating point behaviour is
implementation-dependant, but for systems where special values such as
nan, inf etc are supported, it would be nice (IMHO) for Python to
support them to some degree too. Is this possible or does it get too
bogged down with implementation specifics? A <nasty> solution I guess
would be to do something like
my_float = float("nan")
If str(my_float) == "nan":
doSomething()
But that's awful!
Any help or reasons why the functionality isn't provided would be
gratefully received!
Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20071203/74c84038/attachment.html>
More information about the Python-list
mailing list