On Wed, Dec 8, 2010 at 1:01 PM, John Nagle <na...@animats.com> wrote: > On 12/7/2010 3:59 PM, Mark Wooding wrote: >>> >>> Exactly one of >>> > >>> > a> b >>> > a = b >>> > a< b >>> > >>> > is true, or an type exception must be raised. >> >> This will get the numerical people screaming. Non-signalling NaNs are >> useful, and they don't obey these axioms. > > As a sometime numerical person, I've been screaming at this from > the other side. The problem with comparing non-signalling NaNs is that > eventually, the program has to make a control flow decision, and it > may not make it correctly. > > I used to do dynamic simulation engines for animation. I was > probably the first person to get ragdoll physics to work right, > back in 1996-1997. In hard collisions, the program would get > floating point overflows, and I had to abort the interation, back > up, cut the time step down, and go forward again, until the time > step was small enough to allow stable integration. This was > under Windows on x86, where it's possible, in a Windows-dependent > way, to catch signalling NaNs and turn the hardware exception into > a C++ exception. If the computation just plowed ahead with > non-signalling NaNs, with a check at the end, it could go wrong > and produce bad results, because incorrect branches would be taken > and the final bogus results might not contain NaNs. > > I personally think that comparing NaN with numbers or other > NaNs should raise an exception. There's no valid result for > such comparisons.
This, in big letters. Geremy Condra -- http://mail.python.org/mailman/listinfo/python-list