This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: gfortran.dg/large_real_kind_1.f90
On Wed, Sep 28, 2005 at 12:46:46PM +0930, Alan Modra wrote:
> On Tue, Sep 27, 2005 at 06:55:15PM -0700, Steve Kargl wrote:
> > Your patch appears to break the definition of the Fortran
> > model numbers as given in 13.7.1. In particular, if we
> > have
> >
> > program a
> > integer, parameter :: knd = 4 ! Set to IBM Extended kind to see problem.
> > integer b, e, p
> > real(knd) x,y
> > b = radix(x)
> > e = maxexponent(x)
> > p = digits(x)
> > x = huge(x)
> > print*, x
> > print*, (1._knd - real(b,knd)**(-p)) * real(b,knd)**(e-1) * b
> > end program a
> >
> > The printed values need to be the same.
>
> I can't see how we can satisfy the relationship above without either
> a) lying about maxexponent, making it one less than actually supported,
> or
> b) reducing digits to 53, the same as an ieee double, which is silly,
> or
> c) allowing non-canonical representations of some values.
>
> (c) has the problem that it might require special runtime support to
> handle non-canonical representations, making all arithmetic slower, so I
> don't think it is a reasonable option.
>
> The IBM Extended double format has a number of peculiarities, stemming
> from the fact that each long double is comprised of two doubles, with
> the value of the long double being the sum of its component doubles.
> One peculiarity is that the precision is variable, with p == 106 being
> the minimum precision (actually 107 if the ms double is always the long
> double value correctly rounded to double). For instance, you can
> represent x + 1.0, for all x representable as an ieee double. So why is
> failing the relationship above any more of a peculiarity than variable
> precision?
>
The numerical inquiry functions are defined in the Fortran
95 standard in terms of model numbers. The fundamental
parameters are radix b, digits p, and emin and emax (minimum
and maximum exponent). Huge(x) returns the maximum value for
the model number associated with x not the maximum value for
the machine representable number for x. Of the three choices
you list above, (a) is IMHO the correct solution. BTW, what
are b, p, and emax in IBM extended double format and what is
the value of huge() you expect?
--
Steve