This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
wrong results for SPACING and RRSPACING at compile time
- From: dominiq at lps dot ens dot fr (Dominique Dhumieres)
- To: fortran at gcc dot gnu dot org
- Date: Sun, 1 Oct 2006 16:15:35 +0200 (CEST)
- Subject: wrong results for SPACING and RRSPACING at compile time
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