Diffstat (limited to 'noncore/apps/opie-reader/util.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/util.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/noncore/apps/opie-reader/util.cpp b/noncore/apps/opie-reader/util.cpp index a736f8b..2ca1cc8 100644 --- a/noncore/apps/opie-reader/util.cpp +++ b/noncore/apps/opie-reader/util.cpp @@ -1,7 +1,8 @@ #include "util.h" +#include <limits.h> QString filesize(unsigned long l) { char units[] = { 'K', 'M', 'G' }; int iu = 0; while (l > 999 && iu < sizeof(units)) @@ -19,14 +20,22 @@ QString filesize(unsigned long l) QString percent(unsigned long pos, unsigned long len) { unsigned long permil = 0; if (len != 0) { + if (pos > UINT_MAX/1000) + { + unsigned long l1 = (len+500)/1000; + permil = (pos+l1/2)/l1; + } + else + { permil = (1000*pos+len/2)/len; } + } unsigned long percen = permil/10; unsigned long frac = permil - 10*percen; return QString::number(percen) + "." + QString::number(frac); } QString fmt(unsigned long pos, unsigned long len) |