From: mtk Date: Tue, 29 Sep 2009 15:29:01 +0000 (+0000) Subject: brown paper bag bug: replaced 'static char' with std:string as return value X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=e32fa71bbcd6ccbbf988f1077d09f56cf3e2b01a;p=senf.git brown paper bag bug: replaced 'static char' with std:string as return value git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1461 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/Utils/Statistics.cc b/senf/Utils/Statistics.cc index a2363ca..a86f655 100644 --- a/senf/Utils/Statistics.cc +++ b/senf/Utils/Statistics.cc @@ -83,26 +83,31 @@ senf::StatisticsBase::output(unsigned n) // // 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");