changeset 704:b81f21f2c4c3

Not quite so many digits
author Chris Cannam
date Wed, 04 Dec 2013 14:00:27 +0000
parents 084f65094203
children 97ea68f62c1f e5f4385615ac 67e6d518ac27
files layer/LogNumericalScale.cpp
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/layer/LogNumericalScale.cpp	Wed Dec 04 13:39:41 2013 +0000
+++ b/layer/LogNumericalScale.cpp	Wed Dec 04 14:00:27 2013 +0000
@@ -64,6 +64,7 @@
         int prec = trunc(log10f(minDispInc));
         if (prec < 0) dp = -prec;
         round = powf(10.f, prec);
+        if (dp > 4) dp = 4;
 #ifdef DEBUG_TIME_VALUE_LAYER
         cerr << "round = " << round << ", prec = " << prec << ", dp = " << dp << endl;
 #endif
@@ -97,11 +98,13 @@
 	    continue;
         }
 
-	double dv = dispval;
-	int digits = trunc(log10f(dv));
+	int digits = trunc(log10f(dispval));
 	int sf = dp + (digits > 0 ? digits : 0);
 	if (sf < 4) sf = 4;
-	sprintf(buffer, "%.*g", sf, dv);
+#ifdef DEBUG_TIME_VALUE_LAYER
+        cerr << "sf = " << sf << endl;
+#endif
+	sprintf(buffer, "%.*g", sf, dispval);
 
 	QString label = QString(buffer);