float("nan") in set or as key

John Nagle nagle at animats.com
Thu Jun 2 03:15:24 EDT 2011


On 5/31/2011 7:45 PM, Carl Banks wrote:
> Fine, it wasn't "unheard of".  I'm pretty sure the existence of a few
> high end compiler/hardware combinations that supported traps doesn't
> invalidate my basic point.  NaN was needed because few systems had a
> separate path to deal with exceptional situations like producing or
> operating on something that isn't a number.  When they did exist few
> programmers used them.  If floating-point were standardized today it
> might not even have NaN (and definitely wouldn't support the
> ridiculous NaN != NaN), because all modern systems can be expected to
> support exceptions, and modern programmers can be expected to use
> them.

     Actually, it's the older architectures that support exact floating
point exceptions. x86 does, even in the superscalar and 64 bit variants.
But almost none of the RISC machines have exact floating point 
exceptions.  With all the parallelism inside FPUs today, it takes an
elaborate "retirement unit" to back out everything that happened
after the error and leave the CPU in a clean state.  Most RISC
machines don't bother.  ARM machines have both IEEE mode and
"run-fast mode"; the latter doesn't support FPU exceptions
but does support NaNs.

     Many game machines and GPUs don't have full IEEE floating point.
Some don't have exceptions. Others don't have full INF/NaN semantics.

					John Nagle



More information about the Python-list mailing list