Sat, 28 Jan 2017 16:30:27 +0200
Fixed formatFileSize
src/miscallenous.cpp | file | annotate | diff | comparison | revisions |
--- a/src/miscallenous.cpp Sat Jan 28 14:33:09 2017 +0200 +++ b/src/miscallenous.cpp Sat Jan 28 16:30:27 2017 +0200 @@ -88,7 +88,7 @@ QString formatFileSize (qint64 size) { static const QString suffixes[] = {" bytes", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}; - int magnitude = floor(log10(size) + 1e-10); - magnitude = qMin(magnitude, countof(suffixes)); - return QString::number(size) + suffixes[magnitude]; + int magnitude = magnitude = (size > 0) ? floor(log(size) / log(1000) + 1e-10) : 0; + magnitude = qBound(0, magnitude, countof(suffixes) - 1); + return QString::number(size / pow(1000, magnitude)) + suffixes[magnitude]; }