title: Is it possible to get 0 by subtracting two unequal floating point numbers?
body: <p>Is it possible to get division by 0 (or infinity) in the following example? </p>
  
  <pre class="lang-java prettyprint-override"><code>public double calculation(double a, double b)
  {
       if (a == b)
       {
           return 0;
       }
       else
       {
           return 2 / (a - b);
       }
  }
  </code></pre>
  
  <p>In normal cases it will not, of course. But what if <code>a</code> and <code>b</code> are very close, can <code>(a-b)</code> result in being <code>0</code> due to precision of the calculation?</p>
  
  <p>Note that this question is for Java, but I think it will apply to most programming languages.</p>