[Python-Dev] Mixing float and Decimal -- thread reboot (original) (raw)

Steven D'Aprano steve at pearwood.info
Thu Mar 25 11🔞42 CET 2010


On Thu, 25 Mar 2010 05:26:12 am Alexander Belopolsky wrote:

Mark, I wonder if you could describe an algorithm off the top of your head that relies on NaN == NaN being false.

I don't know whether "relies on" is appropriate, but consider:

def myfunc(x, y): if x == y: return 1.0 else: return something_complicated**(x-y)

Optimising floating point code is fraught with dangers (the above fails for x=y=INF as well as NAN) but anything that make Not A Numbers pretend to be numbers is a bad thing.

I'd like to turn the question around ... what algorithms are there that rely on NaN == NaN being True?

-- Steven D'Aprano



More information about the Python-Dev mailing list