9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Bug in print(2) g verb
@ 2013-02-28  2:49 Paul Patience
  2013-03-01  0:08 ` Rob Pike
  0 siblings, 1 reply; 26+ messages in thread
From: Paul Patience @ 2013-02-28  2:49 UTC (permalink / raw)
  To: 9fans

I already sent this mail, but it seems that 9fans didn't
receive it.

The g verb in print(2) does not work properly. The precision
flag (%.ng) is supposed to print n significant figures, but
it prints n+1 significant figures. This change fixes this
behaviour.

diff -r d6b623d4cac0 sys/src/libc/fmt/fltfmt.c
--- a/sys/src/libc/fmt/fltfmt.c	Sat Feb 23 14:05:51 2013 +0100
+++ b/sys/src/libc/fmt/fltfmt.c	Wed Feb 27 15:59:34 2013 -0500
@@ -187,6 +187,8 @@
 	 * c3 digits of trailing '0'
 	 * c4 digits after '.'
 	 */
+	if(chr == 'g') /* Significant figures. */
+		prec--;
 	c1 = 0;
 	c2 = prec + 1;
 	c3 = 0;





^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2013-03-04  0:39 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-28  2:49 [9fans] Bug in print(2) g verb Paul Patience
2013-03-01  0:08 ` Rob Pike
2013-03-01  2:57   ` Paul A. Patience
2013-03-01  4:54   ` Kurt H Maier
2013-03-01 15:30     ` Rob Pike
2013-03-01 15:58       ` Steve Simon
2013-03-01 17:38         ` Anthony Sorace
2013-03-01 22:53       ` Paul A. Patience
2013-03-03 17:33         ` erik quanstrom
2013-03-03 21:43           ` Richard Miller
2013-03-03 21:52             ` erik quanstrom
2013-03-03 18:54         ` [9fans] doing a native awk port (was Re: Bug in print(2) g verb) arnold
2013-03-03 19:04           ` Paul A. Patience
2013-03-03 19:08             ` erik quanstrom
2013-03-03 19:11               ` Kurt H Maier
2013-03-03 19:18                 ` erik quanstrom
2013-03-03 19:28                   ` Kurt H Maier
2013-03-03 19:31                     ` erik quanstrom
2013-03-03 19:35                       ` Kurt H Maier
2013-03-04  0:10                       ` Dan Cross
2013-03-04  0:39                         ` Kurt H Maier
2013-03-03 19:07           ` erik quanstrom
2013-03-03 21:29             ` Richard Miller
2013-03-03 21:38               ` erik quanstrom
2013-03-03 17:57       ` [9fans] Bug in print(2) g verb Paul A. Patience
2013-03-03 18:26         ` erik quanstrom

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).