title: What is the most effective way for float and double comparison?
body: <p>What would be the most efficient way to compare two <code>double</code> or two <code>float</code> values?</p>
  
  <p>Simply doing this is not correct:</p>
  
  <pre><code>bool CompareDoubles1 (double A, double B)
  {
     return A == B;
  }
  </code></pre>
  
  <p>But something like:</p>
  
  <pre><code>bool CompareDoubles2 (double A, double B) 
  {
     diff = A - B;
     return (diff &lt; EPSILON) &amp;&amp; (-diff &lt; EPSILON);
  }
  </code></pre>
  
  <p>Seems to waste processing.</p>
  
  <p>Does anyone know a smarter float comparer?</p>