wrong results for SPACING and RRSPACING at compile time
Dominique Dhumieres
dominiq@lps.ens.fr
Sun Oct 1 14:15:00 GMT 2006
The following code
real x, xd, xu
x = -3.0*epsilon(x)
xd = abs(fraction(x))*set_exponent(real(radix(x), kind=kind(x)), 1+digits(x))
print *, -3.0*epsilon(1.0)-x
print *, x, spacing(x), spacing(-3.0*epsilon(1.0))
print *, x, xd, rrspacing(x), rrspacing(-3.0*epsilon(1.0))
end
gives
0.000000
-3.5762787E-07 2.8421709E-14 5.6843419E-14
-3.5762787E-07 1.2582912E+07 1.2582912E+07 6291456.
where the last column of the two last lines computed from
spacing(-3.0*epsilon(1.0)) and rrspacing(-3.0*epsilon(1.0))
(hence the 'compile time' in the subject) do not match the
values computed through a variable.
TIA
Dominique
More information about the Fortran
mailing list