title: Any risk of using float variables as loop counters and their fractional increment/decrement for non "==" conditions?
body: <p>Are we safe to use floats as loop-counters and to increment/decrement them by fractional amounts at each iteration,like in the seemingly risk-free program below?Of course I know that using floats as operands for the <strong>==</strong> operator is a dumb thing to do.But what's wrong with using floats as operands for other comparison operations for "normal" purposes? By "normal" I mean that,well,even though floats may not be the <strong>exact</strong> numerical representation of the number,but isn't a variation like <code>0.000000001</code> irrelevant and can be ignored in most cases? (For example in the following program that isn't even apparent)</p>
  
  <p>But that said, here is my apprehension.Suppose the representation isn't exact and <strong>5.0</strong> is actually <strong>4.999999</strong>.So as we go on decrementing by <strong>0.5</strong> at each iteration,the last comparison with <strong>0</strong> may turn out false and the loop may exit due to a difference of <strong>0.000001</strong>,and the last line of current output will not be displayed. I hope you are getting my drift.How wrong am I?</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main(void)
  {
  float f;
  
  for(f=5.0;f&gt;=0;f-=0.5)
  printf("%f\n",f);
  }
  </code></pre>
  
  <p><strong>Output:</strong> </p>
  
  <pre><code>5.000000
  4.500000
  4.000000
  3.500000
  3.000000
  2.500000
  2.000000
  1.500000
  1.000000
  0.500000
  0.000000
  </code></pre>