# HG changeset patch # User Teemu Piippo # Date 1485613827 -7200 # Node ID 8199738646201aa11f4cbf5f56e5fa8f7368af69 # Parent d7ec12688716884405e544b579a147f654510e93 Fixed formatFileSize diff -r d7ec12688716 -r 819973864620 src/miscallenous.cpp --- 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]; }