Next: Order of Operations Matters
Up: Tipical pitfalls with floating
Previous: Cancellation (``Loss-of Significance'') Errors
Consider the Fortran code
real :: x=100000.0, y=100000.1, z
z = y-x
end program test
We would expect the output
but in fact the program prints (on Alpha ...)
Since single precision handles about 7 decimal digits, and the subtraction
cancels the most significant 6, the result contains only
one significant digit. The appended garbage 15625 are insignificant digits,
coming from the inexact binary representation of x and y.
Beware of convincing-looking results!