Overflow error

Paul Rubin http
Wed Jul 28 19:15:07 EDT 2004


janeaustine50 at hotmail.com (Jane Austine) writes:
> >>> from math import e
> >>> e**709
> 8.218407461554662e+307
> >>> e**710
> 
> Traceback (most recent call last):
>   File "<pyshell#15>", line 1, in -toplevel-
>     e**710
> OverflowError: (34, 'Result too large')
> 
> What should I do to calculate e**710?

Is this a homework problem?

Aw heck, you can do something like this:

    from math import *
    a,b = divmod(710 * log10(e), 1.0)  # int and frac parts of log10(e**710)
    print '%f * 10**%d'%(10.** b, a)

This prints: 2.233995 * 10**308



More information about the Python-list mailing list