On Thu, Jan 26, 2012 at 5:53 AM, Intransition <transfire / gmail.com> wrote:
> [...]
>
> But try 1.1, 1.0 and d=0.1
>
> (1.1 / 1.0 - 1).abs <= 0.1
>
> and it is false though it should be true b/c
>
> (1.1 / 1.0 - 1).abs#=> 0.10000000000000009
>
> Which is exactly what instigated my micro-rant. Any advice?

This isn't a problem.  The aim here is to test float equality.  The
test should return true iff a human would look at the two floats and
say "yep, they're meant to be the same thing, it's just the electrical
engineering that got in the way".

1.0 and 1.1 are not float-equal in this sense -- not even close -- and
0.1 is a ridiculous tolerance for testing float ratio.  I'm sure you
were just experimenting, but what I'm saying is: your counterexample
doesn't undermine the overall approach.