title: Python decimal.Decimal - getcontext().prec setting and number of decimals in output
body: <p>I want to do arithmetic with converted number strings using decimal.Decimal. I want the return to have two decimals regardless of the quantity of decimals the converted number strings have.</p>
  <p>In this particular case, why does two decimal precision give me one decimal return and why does three decimal precision give me the return I want (2 decimals -&gt; 2.15)</p>
  <pre><code>from decimal import *
  getcontext().prec = 2
  a = Decimal(x.replace(',','.'))
  b = Decimal(y.replace(',','.'))
  print(a), print(b), print(a-b)
  &gt;&gt;&gt; 2.60 0.45 2.2
  
  getcontext().prec = 3
  a = Decimal(x.replace(',','.'))
  b = Decimal(y.replace(',','.'))
  print(a, b, a-b)
  &gt;&gt;&gt; 2.60 0.45 2.15
  </code></pre>