float literal too large

Warren B. Focke moron at Glue.umd.edu
Tue Jun 27 14:52:27 EDT 2000


Victor S. Miller said:

> float() literal too large.
> 
> The literal in question was '0.23489798479873E-2325' (this was
> generated on a Cray computer).  I couldn't find anything in the
> documentation about this restriction.

Python floats are stored in platform doubles.  On IEEE-754 compliant
hardware (pretty much anything other than a Cray (or VAX, but I don't
think they make those anymore (unless alphas have a VAX math mode)))
that means you get a 53-bit mantissa multiplied by a factor ranging
from 2**-1022 to 2**1023 (or down to 2**-1072 with precision loss).
In decimal that's 14 to 17 digits of mantissa (depending on how you
define precision) and an exponent range of -307 to +307 (or maybe 308,
for some values of the mantissa), and down to -322 with precision
loss.

It is kind of odd that it said it was too big.  One might even go so
far as to call it a bug.

as far as workarounds, what's wrong with

	a[i, j] = eval(s)

?

Warren Focke

-- 
If you feel that you have both feet planted on level ground, then the
university has failed you. -Robert Goheen, President, Princeton University



More information about the Python-list mailing list