Re: atof and VC7.1

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Mycroft Holmes (m.holmes_at_nospam.it)
Date: 07/06/04


Date: Tue, 6 Jul 2004 09:12:32 +0200


> Scientific programmers (who use floating point all the time) learn
> at their mother's knee NEVER to test for equality of floating point
> numbers. There are one or two exceptions (like testing for zero)
> but on the whole, even in that case, you are usually asking the
> wrong question.
>
> Usually what you need to know is
>
> if( abs( a-b) < epsilon )....;
>
> or some variation on this.
>

testing Ša-bŠ<eps is more a problem than a solution.
usually it applies when comparing a result with a constant, definetly not
when comparing two constants.

see for example (you already know it for sure)
http://cch.loria.fr/documentation/IEEE754/numerical_comp_guide/goldberg1.doc.html#674

-- 
 The set of solutions is never empty.
 Two solutions together form a new problem.
-- Mycroft Holmes


Relevant Pages

  • Re: Float point comparison-Newbie
    ... Floating point calculations are often subject ... to *NOT* come out exactly zero. ... If the floating point variable got the value 0.0 because you assigned ... There are two commonly used methods of comparing two floating point ...
    (comp.lang.c)
  • Re: Delphi is mature, no more childish dreams
    ... > Also, when using this setting, you'll no longer get floating ... > point exceptions on divide by zero, ...
    (borland.public.delphi.non-technical)
  • Re: comparing two equal size vectors
    ... I am comparing two equal size vectors. ... Both vectors are double and vector B consists of values that should be in A, otherwise it's zero. ... May be you have floating point errors that prevent the above to work correctly? ...
    (comp.soft-sys.matlab)
  • Re: Comparission cause problem
    ... > Now my concern about my code is that In some palces I am comparing the ... It is a principal problem in how floating point works in computers. ... Always take an epsilon value into account. ... due to different ranges (such as adding or subtracting values whos range ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Problem with floating point numbers.
    ... you are comparing to 4.5 and hoping that magically all the round off ... The floating point problem is not unique to SKILL. ... One good way of comparing floating point numbers in SKILL is to compare ... their printed representations because that is most often what you ...
    (comp.cad.cadence)