From: Guilherme Maciel Ferreira Date: Fri, 28 Jan 2011 16:49:51 +0000 (+0100) Subject: Change nice_unit_format() to long long X-Git-Tag: v2.6~86^2~19 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=242c0a5143aa286a78871e3c4f21bcdb10ba1fcc;p=libi2ncommon Change nice_unit_format() to long long - increased variable size to accommodate bigger byte amounts --- diff --git a/src/stringfunc.cpp b/src/stringfunc.cpp index 16cd6bd..d9050aa 100644 --- a/src/stringfunc.cpp +++ b/src/stringfunc.cpp @@ -892,9 +892,9 @@ string to_upper(const string &src) } #endif -string nice_unit_format(int input) +string nice_unit_format(long long input) { - float size = input; + double size = input; int sizecount = 0; while (size > 1000) @@ -903,11 +903,11 @@ string nice_unit_format(int input) sizecount++; } - float tmp; // round + double tmp; // round tmp = size*10; tmp += 0.5; - tmp = int (tmp); - tmp = float (tmp) /float (10); + tmp = (long long) (tmp); + tmp = double (tmp) /double (10); size = tmp; ostringstream out; diff --git a/src/stringfunc.hxx b/src/stringfunc.hxx index b211a17..660c081 100644 --- a/src/stringfunc.hxx +++ b/src/stringfunc.hxx @@ -190,7 +190,7 @@ using I2n::to_lower; using I2n::to_upper; #endif -std::string nice_unit_format(int input); +std::string nice_unit_format(long long input); bool replace_all(std::string &base, const std::string *ist, const std::string *soll); bool replace_all(std::string &base, const char *ist, const char *soll);