[Bug libfortran/48511] Implement Steele-White algorithm for numeric output

jb at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sun Apr 10 12:25:00 GMT 2011


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48511

--- Comment #6 from Janne Blomqvist <jb at gcc dot gnu.org> 2011-04-10 12:24:54 UTC ---
(In reply to comment #5)
> (In reply to comment #4)
> > (In reply to comment #3)
> > > Does any of the Fortran edit descriptors require, or for that matter allow,
> > > this kind of "shortest decimal representation" output?
> > 
> > Well, the obvious(?) answer is the various descriptors with 0 width.
> 
> Not quite:
> 
> Since we're not talking about the shortest width (w) but the smallest number of
> decimal digits in the fraction (d), only those descriptors where we can select
> "a processor-dependent reasonable value for d" can be "shortened":
> 
> That would be list-directed and G0 (but not G0.d).

What I meant was edit descriptors with w=0 and where d is not present. Sorry if
that wasn't clear.

> For all others the algorithm is still useful if we append zeros to fill the
> required width: it is better to print 0.3000000 than 0.2999996

I don't this is useful, actually. If the user explicitly asks for d decimal
digits, we should use the existing simple algorithm ("simple" compared to the
shortest-width one) to round to d digits, rather than finding the shortest
representation and pad with zeros if necessary.

> I'm still not sure where the Fortran standard says "a processor-dependent
> reasonable value for d"

I don't think you'll find that anywhere. If d is present, d digits must be
printed, assuming it fits in the field width. 

> that includes a "processor-dependent reasonable value
> for d which also depends on the internal value to be printed" because that
> would mess up tabular aligment for printing. This might be a feature users rely
> on.

I think the intention with the w=0 edit descriptors is exactly that, the
compiler can choose the minimum width depending on the value (this being the
case where the shortest-width algorithm can be useful). If the user doesn't
want that, he can choose a non-zero width.



More information about the Gcc-bugs mailing list