removed spurious '%'
[senf.git] / senf / Utils / Statistics.cc
index a9cb325..cc13424 100644 (file)
@@ -81,28 +81,33 @@ senf::StatisticsBase::output(unsigned n)
 }
 
 //
-// generate an engineering style notation i
+// generate an engineering style notation 
 //
-char *format_eng( float f)
+std::string format_eng( float f)
 {
-    static char buf[16];
+    char buf[16];
     if (f > 0) {
         int n = 0;
         while( f >= 1000.0f) {
-                f /= 1000.f;
+                f /= 1000.0f;
                 n+=3;
         }
 
-        sprintf( buf, " %3.2fe%+03d", f, n);
+        if( n >=3)
+            sprintf( buf, " %3.2fe%+03d", f, n);
+        else
+            sprintf( buf, "      %3.2f", f);
     }
     else if (f < 0) {
         int n = 0;
         while( f <= -1000.0f) {
-                f *= 1000.f;
+                f *= 1000.0f;
                 n+=3;
         }
-
-        sprintf( buf, "%3.2fe%+03d", f, n);
+        if( n >=3)
+            sprintf( buf, " %3.2fe%+03d", f, n);
+        else
+            sprintf( buf, "      %3.2f", f);
     }
     else{
         sprintf( buf, "        0.00");
@@ -290,7 +295,7 @@ prefix_ void senf::Collector::enter(float min, float avg, float max)
     if (min < accMin_) accMin_ = min;
     if (max > accMax_) accMax_ = max;
     if (++i_ >= rank_) {
-        StatisticsBase::enter(accMin_, accAvg_ / rank_, accMax_);
+        StatisticsBase::enter(accMin_, accAvg_ / i_, accMax_);
         i_ = 0;
         accMin_ = FLT_MAX;
         accAvg_ = 0.0f;