Python: OverflowError: math range error

Harpal picture Harpal · Oct 29, 2010 · Viewed 92.5k times · Source

I get a Overflow error when i try this calculation, but i cant figure out why.

1-math.exp(-4*1000000*-0.0641515994108)

Answer

Glenn Maynard picture Glenn Maynard · Oct 29, 2010

The number you're asking math.exp to calculate has, in decimal, over 110,000 digits. That's slightly outside of the range of a double, so it causes an overflow.