jonas at zeus.rug.ac.be
Mon Oct 15 15:20:41 CEST 2001
On maandag, oktober 15, 2001, at 09:25 , Michael Van Canneyt wrote:
>> const Epsilon = 1.0e-9;
>> if (x-1)<=Epsilon then x:=1;
>> if (x+1)<=Epsilon then x:=-1;
>> I made these changes because of InvalidArgument exception when arcsin
>> parameter (displayed by GDB) is 1 (but, I think, it was near 1, but
>> not 1).
> But if it is larger than 1, arcsin is not defined ?
> You deliberately introduce an error in the calculation in this way ?
The problem is that floats on computers are inherently inexact and if
you perform a number of calculations the results becomes more inexact
after every operation (I had a lot of trouble with this while
implementing the str_real() routine). You should indeed work with a
small epsilon to compensate for this, but the size of this epsilon
depends on the size of the best real type available (for extended = 10
bytes, it could be 1.0e-9, but for extended = 8 bytes, it will be
> Because then reals are used for the comparision, since in the case
> of abs(X) > 1 the '1' will probably be interpreted as an integer.
No, if one operand in an expression is a float, everything will be
converted to a float.
More information about the fpc-devel