delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/03/01/21:00:26

From: Erik Max Francis <max AT alcyone DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: printf 'g' conversion
Date: Sun, 01 Mar 1998 17:35:17 -0800
Organization: Alcyone Systems
Lines: 38
Message-ID: <34FA0CD5.79608BBD@alcyone.com>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 980301131518 DOT 13547I-100000 AT is> <34FA0346 DOT 33 AT ee DOT washington DOT edu>
NNTP-Posting-Host: newton.alcyone.com
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Ned Ulbricht wrote:

> The Working Draft, 97-11-21, WG14/N794 J11/97-158, p.290 (&cf p.287),
> seems to be a little bit ambiguous about this, but it says under 'g,G'
> "the number is converted in style f or e (...), with the precision
> specifying the number of significant digits." I interpret the "with"
> as
> saying that the g,G format always applies its own semantics to
> precision
> irrespective of the "style" used for the output. I.e. it consistently
> takes over the meaning of precision.
> 
> I can read K&RII either way, so no help there...

Why not look at the _actual_ ANSI document?  From ANSI 7.9.6.1:

    The double argument is converted in style f or e (or in style E in
    the case of a G conversion specifier), with the precision specifying
    the number of significant digits.  If the precision is zero, it is
    taken as 1.

And for f:

    ... If the precision is missing, it is taken as 6 ...

And for e, E:

    ... if the precision is missing, it is taken as 6 ...

Seems pretty clear to me.

-- 
         Erik Max Francis, &tSftDotIotE / mailto:max AT alcyone DOT com
                       Alcyone Systems / http://www.alcyone.com/max/
  San Jose, California, United States / icbm://+37.20.07/-121.53.38
                                     \
        "I've got the fever for the / flavor of a cracker"
                                   / Ice Cube

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019