9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] print conversions
@ 2010-08-16 16:30 hugo rivera
  0 siblings, 0 replies; only message in thread
From: hugo rivera @ 2010-08-16 16:30 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hi,
I'm trying to print floating point numbers, but I get one extra digit
when I use the g verb. Quoting from print(2),
"... and precision is the maximum number of significant digits for g
and G conversions."; so I expect
print("%.2g\n", 1234.567);
to produce
1.2e+03
but I get
1.23e+03
it seems that print(2) uses printf rules for setting the number of
decimals, which will produce the number of significant digits plus
one. I guess that the man page or the implementation needs to be
corrected, but I could be wrong.
Saludos

--
Hugo



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-16 16:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-16 16:30 [9fans] print conversions hugo rivera

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).