title: Floating point equality and tolerances
body: <p>Comparing  two floating point number by something like <code>a_float == b_float</code> is looking for trouble since <code>a_float / 3.0 * 3.0</code> might not be equal to <code>a_float</code> due to round off error.</p>
  
  <p>What one normally does is something like <code>fabs(a_float - b_float) &lt; tol</code>.</p>
  
  <p>How does one calculate <code>tol</code>?</p>
  
  <p>Ideally tolerance should be just larger than the value of one or two of the least significant figures.  So if the single precision floating point number is use <code>tol = 10E-6</code> should be about right. However this does not work well for the general case where <code>a_float</code> might be very small or might be very large. </p>
  
  <p>How does one calculate <code>tol</code> correctly for all general cases? I am interested in C or C++ cases specifically.</p>