From 242c0a5143aa286a78871e3c4f21bcdb10ba1fcc Mon Sep 17 00:00:00 2001 From: Guilherme Maciel Ferreira Date: Fri, 28 Jan 2011 17:49:51 +0100 Subject: [PATCH] Change nice_unit_format() to long long - increased variable size to accommodate bigger byte amounts --- src/stringfunc.cpp | 10 +++++----- src/stringfunc.hxx | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) 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); -- 1.7.1