%g format in printf

Wm E Davidsen Jr davidsen at crdos1.crd.ge.COM
Thu Sep 7 02:14:42 AEST 1989


In article <1439 at hiatus.dec.com>, daniels at grue.dec.com (Bradford R. Daniels) writes:

|  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?

  I learned the same thing. The term used in K&R 1st ed is "precision,"
and the book states that it is not the same as significance. I once (in
error) wrote a printf in which the %g value did specify significant
digits. I was wrong in my reading of the standard, but it was useful.
-- 
bill davidsen	(davidsen at crdos1.crd.GE.COM -or- uunet!crdgw1!crdos1!davidsen)
"The world is filled with fools. They blindly follow their so-called
'reason' in the face of the church and common sense. Any fool can see
that the world is flat!" - anon



More information about the Comp.std.c mailing list