[fpc-pascal] Re: Why this evaluates on "if" wrong ?
milan at marusinec.sk
Sun Oct 28 23:09:31 CET 2007
> This behaviour normal and while annoying, it is simply how things work
> in the digital world, you will have to work around it.
oh yes, this is one of the possible workarounds:
function is_equal_dbl(a ,b : double ) : boolean;
epsilon = 1e-14;
result:=Abs(a - b ) < epsilon;
It's just one more funny thing one must realize,
when comparing real numbers with some exact
real constants. After this, I will try to never
compare doubles directly, but using tricks like
above. Because, in this digital world
1 + 0.4 - 0.4 <> 1.
More information about the fpc-pascal