where in Nan defined

Chris Angelico rosuav at gmail.com
Thu Jan 8 15:45:07 CET 2015


On Fri, Jan 9, 2015 at 1:37 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
> Ian Kelly <ian.g.kelly at gmail.com>:
>
>> To get nan as a literal just do:
>>
>>     nan = float("nan")
>
> True, but that got me thinking: what standard Python math operation
> evaluates to NaN?

Subtracting infinity from infinity is one easy way.

>>> 1e309
inf
>>> 1e309-1e309
nan

ChrisA



More information about the Python-list mailing list