title: Python Decimal module giving different numbers than calculator
body: <p>I want to get large amount of accurate digits in results from divisions, such as 1/7, but Python gives different results than a high-precision calculator.</p>
  
  <p>I tried the decimal library with Python 3 and tried changing its precision and rounding mode, but it gives a different result than a calculator.</p>
  
  <pre><code>from decimal import *
  getcontext().prec = 40
  print (Decimal(1/7))
  </code></pre>
  
  <p>A high-precision calculator at <a href="https://keisan.casio.com/calculator" rel="nofollow noreferrer">https://keisan.casio.com/calculator</a> says the result is a repeating pattern of 142857, but Python's result breaks this pattern after 16 digits. Here is the number it gives:</p>
  
  <pre><code>0.142857142857142849212692681248881854116916656494140625
  </code></pre>