title: Does "epsilon" really guarantees anything in floating-point computations?
body: <p>To make the problem short let's say I want to compute the expression <code>a / (b - c)</code> on <code>float</code>s.</p>
  <p>To make sure the result is meaningful, I can check if <code>b</code> and <code>c</code> are in equal:</p>
  
  <pre class="lang-c++ prettyprint-override"><code>float EPS = std::numeric_limits&lt;float&gt;::epsilon();
  if ((b - c) &gt; EPS || (c - b) &gt; EPS)
  {
      return a / (b - c);
  }
  </code></pre>
  <p>but my tests show it is not enough to guarantee either meaningful results nor not failing to provide a result if it is possible.</p>
  <h1>Case 1:</h1>
  <pre class="lang-c++ prettyprint-override"><code>a = 1.0f;
  b = 0.00000003f;
  c = 0.00000002f;
  </code></pre>
  <p><strong>Result:</strong> The if condition is NOT met, but the expression would produce a correct result 100000008 (as for the floats' precision).</p>
  <h1>Case 2:</h1>
  <pre class="lang-c++ prettyprint-override"><code>a = 1e33f;
  b = 0.000003;
  c = 0.000002;
  </code></pre>
  <p><strong>Result:</strong> The if condition is met, but the expression produces not a meaningful result <code>+1.#INF00</code>.</p>
  <p>I found it much more reliable to check the result, not the arguments:</p>
  <pre class="lang-c++ prettyprint-override"><code>const float INF = numeric_limits&lt;float&gt;::infinity();
  float x = a / (b - c);
  if (-INF &lt; x &amp;&amp; x &lt; INF)
  {
       return x;
  }
  </code></pre>
  <p>But what for is the epsilon then and why is everyone saying epsilon is good to use?</p>