Next: Control Constructs
Up: More About Operations
Previous: Cost of Arithmetic Operators
Since real numbers are stored approximately:
- every operation yields a slight loss of accuracy,
- after many operations such 'round-off' errors build up,
- catastrophic accuracy loss can arise when values that are almost
equal are subtracted, leading digits are cancelled and a rounding errors
become visible.
Consider,
x = 0.123456; y = 0.123446
PRINT*, "x = ",x," y = ",y
PRINT*, "x-y = ",x-y," should be 0.100d-4"
May produce:
x = 0.123457 y = 0.123445
x-y = 0.130d-4 should be 0.100d-4
which is 30% in error.
A whole branch of Numerical Analysis is dedicated to minimising this
class of errors in algorithms. Be careful!
For more information, click here
Next: Control Constructs
Up: More About Operations
Previous: Cost of Arithmetic Operators
©University of Liverpool, 1997
Wed May 28 23:37:18 BST 1997Not for commercial use.