Browse Source

Pad out the suffix string function with zeroes on the right.

Con Kolivas 13 years ago
parent
commit
54d2999d77
1 changed files with 7 additions and 2 deletions
  1. 7 2
      cgminer.c

+ 7 - 2
cgminer.c

@@ -1501,8 +1501,13 @@ static void suffix_string(uint64_t val, char *buf, int sigdigits)
 
 	if (!sigdigits)
 		sprintf(buf, "%d%s", (unsigned int)dval, suffix);
-	else
-		sprintf(buf, "%-*.*g%s", sigdigits + 1, sigdigits, dval, suffix);
+	else {
+		/* Always show sigdigits + 1, padded on right with zeroes
+		 * followed by suffix */
+		int ndigits = (sigdigits - 1 - floor(log10 (dval)));
+
+		sprintf(buf, "%*.*f%s", sigdigits + 1, ndigits, dval, suffix);
+	}
 }
 
 static void get_statline(char *buf, struct cgpu_info *cgpu)