shithub: riscv

Download patch

ref: 24ea306fa66c77739d4c35c892bdf1283f51bb33
parent: 6b03a9495c6b67c691665821bc04633d326516cb
author: ppatience0 <[email protected]>
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;