float literal too large

Victor S. Miller victor at idaccr.org
Tue Jun 27 10:46:05 EDT 2000


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).  Now,
on general grounds I would rather convert this using float, because I
had a statement like

a[i,j] = float(s)

where a is a numerical python array.  So, is there some way around
this?  How do I find out what the restrictions on literals are?

I'm running:

Python 1.5.2 (#4, Nov 23 1999, 14:57:03)  [GCC 2.7.2.2] on sunos5
-- 
Victor S. Miller     | " ... Meanwhile, those of us who can compute can hardly
victor at idaccr.org    | be expected to keep writing papers saying 'I can do the
CCR, Princeton, NJ   | following useless calculation in 2 seconds', and indeed
    08540 USA        | what editor would publish them?"  -- Oliver Atkin



More information about the Python-list mailing list