title: Doing arithmetic with up to two decimal places in Python?
body: <p>I have two floats in Python that I'd like to subtract, i.e.</p>
  
  <pre><code>v1 = float(value1)
  v2 = float(value2)
  diff = v1 - v2
  </code></pre>
  
  <p>I want "diff" to be computed up to two decimal places, that is compute it using <code>%.2f</code> of v1 and <code>%.2f</code> of v2.  How can I do this?  I know how to print v1 and v2 up to two decimals, but not how to do arithmetic like that.</p>
  
  <p>The particular issue I am trying to avoid is this.  Suppose that:</p>
  
  <pre><code>v1 = 0.982769777778
  v2 = 0.985980444444
  diff = v1 - v2
  </code></pre>
  
  <p>and then I print to file the following:</p>
  
  <pre><code>myfile.write("%.2f\t%.2f\t%.2f\n" %(v1, v2, diff))
  </code></pre>
  
  <p>then I will get the output: 0.98 0.99 0.00, suggesting that there's no difference between v1 and v2, even though the printed result suggests there's a 0.01 difference.  How can I get around this?</p>
  
  <p>thanks.</p>