Pay attention to the size and the engineering units. Numbers very close to zero can appear to be different, but the difference is not significant, especially if this number is the difference between two large numbers. For example, 1.9999999e-30 is very near -9.9992112e-33, even though they differ in sign.
VAX math is not as accurate as IEEE math, and even different IEEE processors may differ. This is especially true if the mathematics involves many trigonometric functions. These functions are much more complicated than one might think, and the standard defines only the basic arithmetic functions. There can be subtle differences, even between IEEE machines. Review Chapter Chapter 6, Floating-Point Arithmetic regarding floating-point issues.
Try running with a call nonstandard_arithmetic(). Doing so can also improve performance considerably, and make your Sun workstation behave more like a VAX system. If you have access to a VAX or some other system, run it there also. It is quite common for many numerical applications to produce slightly different results on each floating-point implementation.
Check for NaN, +Inf, and other signs of probable errors. See Chapter Chapter 6, Floating-Point Arithmetic, or the man page ieee_handler(3m) for instructions on how to trap the various exceptions. On most machines, these exceptions simply abort the run.
Two numbers can differ by 6 x 1029 and still have the same floating-point form. Here is an example of different numbers, with the same representation:
real*4 x,y x=99999990e+29 y=99999996e+29 write (*,10) x, x 10 format(’99,999,990 x 10^29 = ’, e14.8, ’ = ’, z8) write(*,20) y, y 20 format(’99,999,996 x 10^29 = ’, e14.8, ’ = ’, z8) end |
The output is:
99,999,990 x 10^29 = 0.99999993E+37 = 7CF0BDC1 99,999,996 x 10^29 = 0.99999993E+37 = 7CF0BDC1 |
In this example, the difference is 6 x 1029. The reason for this indistinguishable, wide gap is that in IEEE single-precision arithmetic, you are guaranteed only six decimal digits for any one decimal-to-binary conversion. You may be able to convert seven or eight digits correctly, but it depends on the number.