Overflow error

  • Thread starter Satchidanand Haridas
  • Start date
S

Satchidanand Haridas

janeaustine50 at hotmail.com said:
/ >>> 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?
/
While float may not be able to handle such large numbers, the 'long' data-type is capable of unlimited precision limited only by your system memory.

You could cast the above floats to long and then do the needed calculation. But note that long floors a floating number. So:

long(e) will return 2.

So you will have to consider the fractional part while multiplying to avoid rounding-off errors. Something like this:

Hope this was of some help.

Regards,
Satchit

----
Satchidanand Haridas (sharidas at zeomega dot com)

ZeOmega (www.zeomega.com)
Open Minds' Open Solutions

#20,Rajalakshmi Plaza,
South End Road,
Basavanagudi,
Bangalore-560 004, India
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top