float literal too large
Tim Peters
tim_one at email.msn.com
Wed Jun 28 00:40:35 EDT 2000
[posted & mailed]
> I just wrote a python program to read output produced by a Fortran
> program that somebody had written. Much to my surprise I got the
> exception:
>
> 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. Even more puzzling was the fact
> that eval() worked just fine (it gave the answer 0.0 which is
> perfectly acceptable to me, given that the platform on which I was
> running had less precision than the platform that generated it). ...
> ...
> I'm running:
>
> Python 1.5.2 (#4, Nov 23 1999, 14:57:03) [GCC 2.7.2.2] on sunos5
This inconsistency in 1.5.2 was inherited from the differing behaviors of
atof and strtod in your glibc. It should be fixed for you in 1.6; e.g., but
under WinTel (which also used to display the inconsistency in 1.5.2) 1.6a2:
C:\Python16>python
Python 1.6a2 (#0, Apr 6 2000, 11:45:12) [MSC 32 bit (Intel)] on win32
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> float(0.23489798479873E-2325)
0.0
>>> eval("0.23489798479873E-2325")
0.0
>>> x = 0.23489798479873E-2325
>>> x
0.0
>>>
More information about the Python-list
mailing list