2012/1/26 Bartosz Dziewoski <matma.rex / gmail.com>:
> Generally, you should use ratio instead of difference when comparing
> floats, but in many cases - such as the time one provided by Alex - a
> difference is obviously a better idea.
>
> There is no silver bullet, just use whatever works for you in a particular case.

I doubt that difference is a better idea "in many cases" and I don't
think the time example is even valid, though I could be wrong.  Got
any other examples?

As for no silver bullet, the problem of comparing floats arises from
engineering and should be solved by engineering, not by whatever works
in a particular case.  So while I don't _have_ a silver bullet, my gut
feeling says there _is_ one.

I'm sure in particular programs, near enough is good enough.  If Bob's
program thinks 39.5 and 39.47 are close enough to be called "equal",
then that's a test Bob needs to implement himself, in both his program
and his tests.  It has nothing whatsoever to do with "float equality"
in a standard unit testing sense.