wrong results for SPACING and RRSPACING at compile time

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Oct 2 19:06:00 GMT 2006


On Sun, Oct 01, 2006 at 04:15:35PM +0200, Dominique Dhumieres wrote:
> 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.
> 

Dominique,

I've looked at this a little bit and I think I have the 
the handling of subnormal numbers worked out.  However,
I think gfortran's constant folding of spacing and rrspacing 
may be broken for special cases.  I need to go read the
standard for these intrinsics.

-- 
Steve



More information about the Fortran mailing list