From: Yossef Mendelssohn Date: 2012-01-26T14:34:14+09:00 Subject: Re: Microrant on Ruy's Math Skills --000e0ce028a4df337504b767ba56 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Jan 25, 2012 at 7:36 PM, Gavin Sinclair wrote: > On Thu, Jan 26, 2012 at 5:53 AM, Intransition 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 --000e0ce028a4df337504b767ba56--