LOGO-L> Re - floating point errors in MSWLogo 
Author Message
 LOGO-L> Re - floating point errors in MSWLogo

Do not blame Logo for bad addition.
Each computation system based on floating point numbers with finite length will make an error in such operation. In fact we can trace this error with a sheet of paper. Let's assume that we have a calculator with 10 decimal digit. Where both number are near, it is no error in addition:

=0.000000035 OK.

But when one number is substantially greater, we lose part of accuracy:

+  0.000000023
=10.00000003   BAD - we've lost 0.000000003

We may also see additions, which give no effect. For example 1000000000.1+0.0000001 give as the result 1000000000.1

We can use this effect to make some trick. Let's take a look on following procedure
(In this example global Makes are applied intentionally, Yehuda - please don't extract them this time)

to xsum
 make "a0 :a
 make "a :a0 + :delta
 make "b1 :a0 - :a
 make "b2 :b1 + :delta
 make "b :b2 + :b

You may say, that :a0 + :delta - :a0 - :delta  equals 0. This is true in arithmetic, but not on floating point computation. Small difference will be gathered in variable :b. Please repeat xsum 1640 times with :a0=0 :delta=0.02 (all other variables should start with 0 also) and take :a+:b as the result. You will get 32.8 exactly.

Best regards
Andrzej B.


Thu, 11 May 2000 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. LOGO-L> floating point errors in MSWLogo

2. LOGO-L> Floating point errors

3. LOGO-L> Floating point trick once more

4. LOGO-L> Re: floating point errors in MSWLogo

5. LOGO-L> PC-LOGO syntax in MSWLogo

6. An alternative to floating point (was Re: Floating point non-exactness)

7. IBM 370 Floating point to IEEE floating point

8. Runtime Error M6104, Floating point error:overflow

9. LOGO-L> Re: MSWLogo

10. LOGO-L> MSWlogo for D. Barnett

11. LOGO-L> Web page + MSWLogo GUI Builder

12. LOGO-L> Bola magica (MSWLogo)


Powered by phpBB® Forum Software