Browse Source

percentf2 that takes t as precalculated total

Luke Dashjr 12 years ago
parent
commit
a7ca73ec74
1 changed files with 4 additions and 3 deletions
  1. 4 3
      miner.c

+ 4 - 3
miner.c

@@ -2365,13 +2365,13 @@ ti_hashrate_bufstr(char**out, float current, float average, float sharebased, en
 }
 
 static const char *
-percentf(double p, double t, char *buf)
+percentf2(double p, double t, char *buf)
 {
 	if (!p)
 		return "none";
-	if (!t)
+	if (t <= p)
 		return "100%";
-	p /= p + t;
+	p /= t;
 	if (p < 0.01)
 		sprintf(buf, ".%02.0f%%", p * 10000);  // ".01%"
 	else
@@ -2381,6 +2381,7 @@ percentf(double p, double t, char *buf)
 		sprintf(buf, "%3.0f%%", p * 100);  // " 99%"
 	return buf;
 }
+#define percentf(p, t, buf)  percentf2(p, p + t, buf)
 
 #ifdef HAVE_CURSES
 static void adj_width(int var, int *length);