a.index(float('nan')) fails

Terry Reedy tjreedy at udel.edu
Fri Oct 26 03:54:02 EDT 2012


On 10/25/2012 10:44 PM, Steven D'Aprano wrote:
> On Thu, 25 Oct 2012 22:04:52 -0400, Terry Reedy wrote:
>
>> It is a consequence of the following, which some people (but not all)
>> believe is mandated by the IEEE standard.
>>
>>   >>> nan = float('nan')
>>   >>> nan is nan
>> True
>
> The IEEE 754 standard says nothing about object identity. It only
> discusses value equality.
>
>>   >>> nan == nan
>> False
>
> IEEE 754 states that all NANs compare unequal to everything, including
> NANs with the same bit value. It doesn't make an exception for
> comparisons with itself.
>
> I'm not entirely sure why you suggest that there is an argument about
> what IEEE 754 says about NANs.

I did not do so.

> As far as I can see, the argument is
> whether or not language designers should pick and choose which bits of
> the standard they want to follow, thus taking a step backwards to the
> chaos of numerical computing prior to the IEEE 754 standard.

There has been disagreement about whether the standard mandates that 
Python behave the way it does. That is a fact, but I have no interest in 
discussing the issue.

-- 
Terry Jan Reedy




More information about the Python-list mailing list