This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients ethan.furman, mark.dickinson, pitrou, serhiy.storchaka, vstinner
Date 2015-01-09.08:57:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1420793836.41.0.0549154776279.issue23185@psf.upfronthosting.co.za>
In-reply-to
Content
2015-01-09 8:16 GMT+01:00 Serhiy Storchaka <report@bugs.python.org>:
> May be make math.inf and math.nan special objects so that for all x (except inf and nan):

What do you mean? Implement a subtype of float and override some methods?

> x < math.inf
> x > -math.inf

It's already the case for int, float and decimal.Decimal.

> not (x < math.nan)
> not (x > math.nan)

Comparison to nan always return False.

I would be better to raise an error when nan is compared to other numbers (I mean operations like a>b, not a==b), but Python was not designed like that (nor the IEEE 754?).

>>> sorted((nan, 1, nan, 2))
[nan, 1, nan, 2]

Sorting with NaN is a common issue :-/ See for example:
https://stackoverflow.com/questions/4240050/python-sort-function-breaks-in-the-presence-of-nan

Anyway, changing NaN behaviour is out of the scope of this issue!
History
Date User Action Args
2015-01-09 08:57:16vstinnersetrecipients: + vstinner, mark.dickinson, pitrou, ethan.furman, serhiy.storchaka
2015-01-09 08:57:16vstinnersetmessageid: <1420793836.41.0.0549154776279.issue23185@psf.upfronthosting.co.za>
2015-01-09 08:57:16vstinnerlinkissue23185 messages
2015-01-09 08:57:15vstinnercreate