Re: checking for close enough floating point values.



On Fri, 30 May 2008 02:07:53 -0700 (PDT), pereges <Broli00@xxxxxxxxx>
wrote:

On May 30, 9:52 am, Barry Schwarz <schwa...@xxxxxxxx> wrote:

This checks for a == b, not a >= b.

if (a + EPSILON >= b) would be the corresponding check for >=.

However, you should read 14.5 in the c-faq (www.c-faq.com) to see why
an unscaled EPSILON is a bad idea.

So do you think it will be better to use the relative difference
method as suggested in the C faq 14.5 ?


snip

Btw the floating point data that I'm reading has 6 places after the
decimal point so I though I would take a tolerance value of 0.000001.

If you can guarantee that all the data will be within a certain range
then you don't need to scale based on the current value. But what
happens when one set of values is near 1e-6 and another is near 1e10?
That is the point I thought the faq was trying to make.


Remove del for email
.



Relevant Pages

  • Re: checking for close enough floating point values.
    ... if<= EPSILON) ... you should read 14.5 in the c-faq to see why ... an unscaled EPSILON is a bad idea. ... Remove del for email ...
    (comp.lang.c)
  • Re: scanf in a for loop
    ... sachin wrote on 25/12/04: ... No. Please, read the FAQ. ... The C-FAQ: http://www.eskimo.com/~scs/C-faq/faq.html ... "Clearly your code does not meet the original spec." ...
    (comp.lang.c)
  • Re: Dynamically-allocated Multi-dimensional Arrays
    ... I was using something slightly different from the C-FAQ and I was ... Say I want a two-dimensional array, ... and complications. ... The second way listed in the FAQ is what you want: ...
    (comp.lang.c)
  • Re: Use of do...while(0) in ASSERT macro
    ... > Is there any reason to use the first definition? ... This is a comp.lang.c FAQ. ... the C-faq. ...
    (comp.lang.c)
  • Re: A simple math libary problem?
    ... > Why is this in the FAQ? ... Your question is answered in the C-faq. ... Strong enough for a manager, but made for an engineer. ...
    (comp.lang.c)