Comparing of numbers
Floating point numbers cannot be accurately compared for equality.
Rounding and comparing floating point numbers to n-th decimal dogits
- function CompareFloat(E1, E2: Extended; Digits: Integer): Boolean;
// "visual" method, rather slow
var S1, S2: string;
begin
Str(E1: 0: Digits, S1);
Str(E2: 0: Digits, S2);
Result := S1 = S2;
end;
From: "Marek Janaszewski" mjsebek@poczta.onet.pl
source
Bibliografia:
rounding (in Polish)
round function (in Polish)
- manually
- SameValue function
Precision for comparing extended numbers e1 and e2 should be:
- MinExtended < precision < MaxExtended
- Abs(e2-e1)>precision
One can use it instead of Csng Basic function.
Main Page
Feel free to e-mail me!
Author: Adam Majewski adammaj1-at-o2-dot-pl
About
http://republika.pl/fraktal/