On Wed, 09 Jul 2014 13:05:22 -0500, Tim Chase wrote: > If you want to compare things in a NaN-aware way, you can either spell > it out explicitly: > > if x == y or (math.isnan(x) and math.isnan(y)): > do_stuff()
But do we really want any arbitrary NAN to compare equal-ish with every other NAN? There are 9007199254740990 distinct NANs (slightly less than 0.05% of the total number of floats). Much to my disappointment, frexp doesn't return the payload and exponent of NANs, at least not on Linux: py> math.frexp(NAN) (nan, 0) so it can't be used to distinguish different NANs. -- Steven -- https://mail.python.org/mailman/listinfo/python-list