author | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
---|---|---|
committer | pohly <pohly> | 2005-05-05 14:39:33 (UTC) |
commit | 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 (patch) (side-by-side diff) | |
tree | 96e66fdc18dca4d4ab8611133e072f57dea224b9 /noncore/apps/opie-reader/util.cpp | |
parent | 279fc4fd1986074acbadd3a8e86fcf3968a8dd5c (diff) | |
download | opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.zip opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.gz opie-39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91.tar.bz2 |
new opie-reader sources with support for ArriereGo, Reb input and flite output plugins
Diffstat (limited to 'noncore/apps/opie-reader/util.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-reader/util.cpp | 11 |
1 files changed, 10 insertions, 1 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,9 +1,10 @@ #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)) { l = (l+512)/1024; @@ -17,17 +18,25 @@ QString filesize(unsigned long l) return ret; } QString percent(unsigned long pos, unsigned long len) { unsigned long permil = 0; if (len != 0) { - permil = (1000*pos+len/2)/len; + 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) { |