Skip to content

Commit 200b503

Browse files
author
wodry
committed
Fix wrong(1024) divisor for 1000-based prefixes
1 parent eceb3f7 commit 200b503

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/qt/guiutil.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -759,14 +759,14 @@ QString formatNiceTimeOffset(qint64 secs)
759759

760760
QString formatBytes(uint64_t bytes)
761761
{
762-
if(bytes < 1024)
762+
if(bytes < 1000)
763763
return QObject::tr("%1 B").arg(bytes);
764-
if(bytes < 1024 * 1024)
765-
return QObject::tr("%1 KB").arg(bytes / 1024);
766-
if(bytes < 1024 * 1024 * 1024)
767-
return QObject::tr("%1 MB").arg(bytes / 1024 / 1024);
764+
if(bytes < 1000 * 1000)
765+
return QObject::tr("%1 kB").arg(bytes / 1000);
766+
if(bytes < 1000 * 1000 * 1000)
767+
return QObject::tr("%1 MB").arg(bytes / 1000 / 1000);
768768

769-
return QObject::tr("%1 GB").arg(bytes / 1024 / 1024 / 1024);
769+
return QObject::tr("%1 GB").arg(bytes / 1000 / 1000 / 1000);
770770
}
771771

772772
qreal calculateIdealFontSize(int width, const QString& text, QFont font, qreal minPointSize, qreal font_size) {

src/qt/trafficgraphwidget.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *)
7979
int base = floor(log10(fMax));
8080
float val = pow(10.0f, base);
8181

82-
const QString units = tr("KB/s");
82+
const QString units = tr("kB/s");
8383
const float yMarginText = 2.0;
8484

8585
// draw lines
@@ -128,8 +128,9 @@ void TrafficGraphWidget::updateRates()
128128

129129
quint64 bytesIn = clientModel->node().getTotalBytesRecv(),
130130
bytesOut = clientModel->node().getTotalBytesSent();
131-
float inRate = (bytesIn - nLastBytesIn) / 1024.0f * 1000 / timer->interval();
132-
float outRate = (bytesOut - nLastBytesOut) / 1024.0f * 1000 / timer->interval();
131+
// Rates are in bytes/millisecond which is equal to kilobytes/second
132+
float inRate = (bytesIn - nLastBytesIn) * 1.0f / timer->interval();
133+
float outRate = (bytesOut - nLastBytesOut) * 1.0f / timer->interval();
133134
vSamplesIn.push_front(inRate);
134135
vSamplesOut.push_front(outRate);
135136
nLastBytesIn = bytesIn;

0 commit comments

Comments
 (0)