title: Unexpected loss of precision when dividing doubles
body: <p>I have a function getSlope which takes as parameters 4 doubles and returns another double calculated using this given parameters in the following way:</p>
  
  <pre><code>double QSweep::getSlope(double a, double b, double c, double d){
  double slope;
  slope=(d-b)/(c-a);
  return slope;
  }
  </code></pre>
  
  <p>The problem is that when calling this function with arguments for example:</p>
  
  <pre><code>getSlope(2.71156, -1.64161, 2.70413, -1.72219);
  </code></pre>
  
  <p>the returned result is:</p>
  
  <pre><code>10.8557
  </code></pre>
  
  <p>and this is not a good result for my computations.
  I have calculated the slope using Mathematica and the result for the slope for the same parameters is:</p>
  
  <pre><code>10.8452
  </code></pre>
  
  <p>or with more digits for precision:</p>
  
  <pre><code>10.845222072678331.
  </code></pre>
  
  <p>The result returned by my program is not good in my further computations.
  Moreover, I do not understant how does the program returns 10.8557 starting from     10.845222072678331 (supposing that this is the approximate result for the division)?
  How can I get the good result for my division?</p>
  
  <p>thank you in advance,
  madalina</p>
  
  <hr>
  
  <p>I print the result using the command line:</p>
  
  <pre><code>std::cout&lt;&lt;slope&lt;&lt;endl;
  </code></pre>
  
  <p>It may be that my parameters are maybe not good, as I read them from another program (which computes a graph; after I read this parameters fromt his graph I have just displayed them to see their value but maybe the displayed vectors have not the same internal precision for the calculated value..I do not know it is really strange. Some numerical errors appears..)</p>
  
  <p>When the graph from which I am reading my parameters is computed, some numerical libraries written in C++ (with templates) are used. No OpenGL is used for this computation. </p>
  
  <p>thank you,
  madalina</p>