title: Python: "long int too large to convert to float" when calculating pi
body: <p>I get this error when using a python script that calculates pi using the Gauss-Legendre algorithm. You can only use up to 1024 iterations before getting this:</p>
  
  <pre><code>    C:\Users\myUsernameHere&gt;python Desktop/piWriter.py
      End iteration: 1025
      Traceback (most recent call last):
        File "Desktop/piWriter.py", line 15, in &lt;module&gt;
          vars()['t' + str(sub)] = vars()['t' + str(i)] - vars()['p' + str(i)] * math.
      pow((vars()['a' + str(i)] - vars()['a' + str(sub)]), 2)
      OverflowError: long int too large to convert to float
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>import math
  
  a0 = 1
  b0 = 1/math.sqrt(2)
  t0 = .25
  p0 = 1
  
  finalIter = input('End iteration: ')
  finalIter = int(finalIter)
  
  for i in range(0, finalIter):
          sub = i + 1
          vars()['a' + str(sub)] = (vars()['a' + str(i)] + vars()['b' + str(i)])/ 2
          vars()['b' + str(sub)] = math.sqrt((vars()['a' + str(i)] * vars()['b' + str(i)]))
          vars()['t' + str(sub)] = vars()['t' + str(i)] - vars()['p' + str(i)] * math.pow((vars()['a' + str(i)] - vars()['a' + str(sub)]), 2)
          vars()['p' + str(sub)] = 2 * vars()['p' + str(i)]
          n = i
  
  pi = math.pow((vars()['a' + str(n)] + vars()['b' + str(n)]), 2) / (4 * vars()['t' + str(n)])
  print(pi)
  </code></pre>
  
  <p>Ideally, I want to be able to plug in a very large number as the iteration value and come back a while later to see the result.</p>
  
  <p>Any help appreciated!
  Thanks!</p>