where in Nan defined
steve+comp.lang.python at pearwood.info
Fri Jan 9 02:46:27 CET 2015
Chris Angelico wrote:
> On Fri, Jan 9, 2015 at 1:50 AM, Jussi Piitulainen
> <jpiitula at ling.helsinki.fi> wrote:
>> >>> 0*1e400
> Nice, that's shorter than mine.
Is that really the sort of thing you should be revealing here?
Oh wait, you're talking about code...
I'm not entirely sure, but I suspect that 0*1e400 may not be quite as
portable as your inf-inf. By the rules of IEEE-754 arithmetic, inf-inf has
to return a NAN, but if your floats have sufficient precision available to
represent 1e400, 0*1e400 might return 0.
The fallback rule I use when float('nan') fails is
INF = 1e3000 # Hopefully, this should overflow to INF.
NAN = INF-INF # And this hopefully will give a NaN.
More information about the Python-list