NaN handling

Terry Reedy tjreedy at udel.edu
Sat May 6 13:32:24 EDT 2006


"Ryan Forsythe" <ryanf at cs.uoregon.edu> wrote in message 
news:445CD5E3.1070600 at cs.uoregon.edu...
> Terry Reedy wrote:
>> "Felipe Almeida Lessa" <felipe.lessa at gmail.com> wrote in message
>> news:1146929327.30335.5.camel at kenshin.CASA...
>>> This works everywhere:
>>>
>>> nan = float('nan')
>>
>> Not.
>>
>>>>> nan = float('nan')
>>
>> Traceback (most recent call last):
>>   File "<pyshell#4>", line 1, in -toplevel-
>>     nan = float('nan')
>> ValueError: invalid literal for float(): nan
>>
>> Above is Windows, which requires something else.
>
> I think he meant:
>
> >>> float("NaN")
> nan
>
> That's Python 2.4.1 on Mac OS X.

>>> float("NaN")

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in -toplevel-
    float("NaN")
ValueError: invalid literal for float(): NaN

As Tim Peters has said often enough, this sort of thing is specific to the 
underlying C library and will remain so until someone cares enough to write 
or fund a cross-platform solution.

Terry Jan Reedy






More information about the Python-list mailing list