title: Arithmetic error with double c++
body: <p>I have noticed a small error on some arithmetic calculations using double. It is really weird, there's always a small error and/or an extra significant digit.</p>
  
  <p>First I am using atof to convert a number that has two significant digits that I am reading from a text file (then I record them on a vector):</p>
  
  <pre><code> // Puts into vector
    double ask_file, bid_file; // Values of ask and bid from file
    double cur_conversion = 0.16;
    ask_file = cur_conversion*atof(values[0].c_str()); 
    bid_file = cur_conversion*atof(values[1].c_str()); 
  </code></pre>
  
  <p>Then I am doing the arithmetic (from other class, two different objects):</p>
  
  <pre><code>diff = OKC-&gt;bid_val() - BV-&gt;ask_val(); // diff
  diff2 = OKC-&gt;ask_val() - BV-&gt;bid_val(); // diff2
  </code></pre>
  
  <p>This is the output:</p>
  
  <pre><code>BV Askfile: 245.267 Bidfile: 245.078 
  OKC Askfile: 248.82 Bidfile: 248.73 
  diff: 3.4628 diff2: 3.7416
  </code></pre>
  
  <p>As you can see, there's an error on both calculations. diff = 3.463 and NOT 3.4628. And diff2 = 3.742 and NOT 3.7416.</p>
  
  <p>Do you know what's going on??</p>