Mail Archives: djgpp-workers/1998/07/13/08:06:00
> Yes. It could be argued that 0.012 is only 2 significant digits,
> whereas %.3g requests for 3.
Except that the ANSI spec, when talking about the f type (which the g
type mimics), uses the term "fraction digits" instead of "digits of
precision". I think the intent is that %.3g yields 0.012, not 0.0123
(but it would have printed 1.23E-2).
However, this program:
main()
{
double x = 0.012341234;
printf("%.3e %.3f %.3g\n", x, x, x);
}
Yeilds:
IRIX: 1.234e-02 0.012 0.0123
Linux: 1.234e-02 0.012 0.0123
SunOS4: 1.234e-02 0.012 0.0123
2.02: 1.234e-02 0.012 0.0123
So, I think we should leave it the way it is.
- Raw text -