title: Compare two floats
body: <pre><code>#include &lt;stdbool.h&gt;
  
  bool Equality(double a, double b, double epsilon)
  {
    if (fabs(a-b) &lt; epsilon) return true;
    return false;
  }
  </code></pre>
  
  <p>I tried this method to compare two doubles, but I always get problems since I don't know how to chose the <code>epsilon</code>, actually I want to compare small numbers (6 6 digits after the decimal point) like <em>0.000001</em>. I tried with some numbers, sometimes I get <code>0.000001 != 0.000001</code> and sometimes <code>0.000001 == 0.000002</code>
  Is there another method else than comparing with the epsilon?</p>
  
  <p>My purpose is to compare two doubles (which represent the time in my case). The variable t which represents the time in milliseconds is a double. It is incremented by another function 0.000001 then 0.000002 etc. each time t changes, I want to check if it is equal to another variable of type double tt, in case tt == t, I have some instructions to execute..<br>
  Thanks for your help </p>