where in Nan defined

Jussi Piitulainen jpiitula at ling.helsinki.fi
Thu Jan 8 09:50:04 EST 2015


Marko Rauhamaa writes:
> Ian Kelly:
> 
> > 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?

All manner of arithmetics gives overflow errors ("Numerical result out
of range") but a literal with a large exponent gives an inf, so:

   >>> 0*1e400
   nan

(That's on a Python 3.2.3 ... on linux2.)



More information about the Python-list mailing list