Path: utzoo!attcan!lsuc!sq!msb From: msb@sq.sq.com (Mark Brader) Newsgroups: comp.std.c Subject: Re: %g format in printf Message-ID: <1989Sep9.013233.9939@sq.sq.com> Date: 9 Sep 89 01:32:33 GMT References: <1439@hiatus.dec.com> <19426@mimsy.UUCP> Reply-To: msb@sq.com (Mark Brader) Organization: SoftQuad Inc., Toronto Lines: 33 [Quoting style in quoted messages changed for consistency.] Bradford R. Daniels (daniels@grue.dec.com) writes: > > I learned in my high school ... that if I am asked to print out "1024" > > with 1 significant digit, I should get "1000" printed out. Chris Torek (chris@mimsy.UUCP) writes: > No: "1000" has four significant digits (as does "1.000"); you need "1e3". > I have seen arguments on both sides of this, but only believe the one > that says `the number of digits written is the number of significant > digits'. Well, my high school agreed with Bradford's; I learned that either "1e3" or "1000" had *one* significant digit, and that to write a value of 1000 with four significant digits you had to say "1000." or "1.000e3". (Where "e" is taken as an ASCIIfication of "times sign, 10, superscript:") But such an interpretation of "significant digit" would make section 4.9.6.1 impossible to satisfy for a conversion specification of "%4g" and a value of 1000 -- the wording requires %f style and no trailing period -- so it's clear that the authors of the pANS must have had in mind the interpretation that Chris gives. Given that there seem to be two conflicting interpretations it is a pity that they used the words "significant digits". As for a value of 1024, of course "%.1g" of that should produce "1e3", or rather, "1e+03". -- Mark Brader Summary of issue: Fix FORTRAN-8x. SoftQuad Inc., Toronto Committee Response: This proposal contains utzoo!sq!msb insurmountable technical errors. msb@sq.com -- X3J11 responses to 2nd public review This article is in the public domain.