Commit 65b80476 authored by Karel Slaný's avatar Karel Slaný

Added rounding into approximateDataSize().

parent 7698015e
......@@ -72,7 +72,10 @@ static
QString approximateDataSize(qint64 dataSize)
{
if (dataSize >= 1024) {
return QStringLiteral("~") % QString::number(dataSize / 1024) % QStringLiteral(" kB");
qint64 kBytes = dataSize >> 10; /* dataSize / 1024 */
/* (dataSize % 1024) >= 512 -> increase dicision by 1 */
kBytes += (dataSize & 0x0200) ? 1 : 0; /* ceil((float)(dataSize / 1024)) */
return QStringLiteral("~") % QString::number(kBytes) % QStringLiteral(" kB");
} else {
return QStringLiteral("~") % QString::number(dataSize) % QStringLiteral(" B");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment