On Wed, Jan 25, 2012 at 7:36 PM, Gavin Sinclair <gsinclair / gmail.com> wrote:

> 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".
>

Yes, this is exactly the thing to care about. Thank you.

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.
>

And yes, 0.1 is a ridiculous tolerance and this, to be blunt, is not so
much a "counter" example as a "dumb" one.

-- 
-yossef