%g format in printf

Bradford R. Daniels daniels at grue.dec.com
Wed Sep 6 09:19:47 AEST 1989


What should the default number of significant digits be for the
%g format specifier in printf?  The standard says that an explicit
0 should be treated as a 1, but doesn't say anything about what to
do if no precision is specified.

Right now, the VAX C RTL uses 6 as the default precision.  This
seems reasonable, since 6 is the default precision for the %e
and %f specifiers.  However, precision has a different meaning
with %g than with those other specifiers.  Is VAXCRTL's current
behavior correct?

Also, the definition of significant digits I learned in my high
school science classes says that if I am asked to print out 1024
with 1 significant digit, I should get 1000 printed out.  Is that
correct?

Thanks,
- Brad

-----------------------------------------------------------------
Brad Daniels			|  Digital Equipment Corp. almost
DEC Software Devo		|  definitely wouldn't approve of
"VAX C RTL Whipping Boy"	|  anything I say here...



More information about the Comp.std.c mailing list