git: 9front

Download patch

ref: d33a89f22ba7d5086c84fae65b2c3ef74ce24ada
parent: 58fe582ca95df1f8474fba6fd8d4a1fa9a6d9b1c
author: ppatience0 <ppatience0@gmail.com>
date: Wed Feb 27 11:15:18 EST 2013

fltfmt: %.ng is supposed to print a number with n significant figures, but it prints it with n+1. This fixes that behaviour.

--- a/sys/src/libc/fmt/fltfmt.c
+++ b/sys/src/libc/fmt/fltfmt.c
@@ -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;
--