title: How to store decimal values as a varible
body: <p>I'm writing a program that uses an infinite sum to calculate pi to a large number of decimal places very fast, 22 iterations results in 15 decimal places. However, due to limitations of python this is the maximum number of decimal places that can be shown. So try and fix this issue I looked to the internet and found <a href="https://docs.python.org/3.4/library/decimal.html" rel="nofollow noreferrer">this website</a> that included information on the python decimal class.</p>
  
  <p>This seemed like the perfect solution to my problem, however when trying this method I could not add the numbers and save them to a variable. After going back to the original site to find an answer, I couldn't find anything involving variable. But the page is ludicrously long, and I could have easily missed something.</p>
  
  <p>Here is my code, it works fine with out the decimal part:</p>
  
  <pre><code>from decimal import *
  getcontext().prec = 30
  
  n = 0
  value = 1 / 2
  while True:
      n += 1
      top = 1
      bottom = 2 ** (2 * n + 1) * (2 * n + 1) * 2
      for i in range(n):
          top *= 2 * i + 1
          if i != 0: bottom *= 2 * i + 2
  
      value += Decimal(top) / Decimal(bottom)
      print(value * 6)
  </code></pre>
  
  <p><strong>EDIT:</strong>
  This is the error that I have recieved:</p>
  
  <pre><code>TypeError: unsupported operand type(s) for +=: 'float' and 'decimal.Decimal'
  </code></pre>
  
  <p>This is the first time that I have worked with this class and I am unsure how to contiune.</p>