Skip to content

Commit d09ebc4

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

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/qt/guiutil.cpp

Lines changed: 6 additions & 6 deletions
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 < 1'000)
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 < 1'000'000)
765+
return QObject::tr("%1 kB").arg(bytes / 1'000);
766+
if (bytes < 1'000'000'000)
767+
return QObject::tr("%1 MB").arg(bytes / 1'000'000);
768768

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

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

src/qt/trafficgraphwidget.cpp

Lines changed: 5 additions & 5 deletions
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,10 +128,10 @@ 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();
133-
vSamplesIn.push_front(inRate);
134-
vSamplesOut.push_front(outRate);
131+
float in_rate_kilobytes_per_sec = static_cast<float>(bytesIn - nLastBytesIn) / timer->interval();
132+
float out_rate_kilobytes_per_sec = static_cast<float>(bytesOut - nLastBytesOut) / timer->interval();
133+
vSamplesIn.push_front(in_rate_kilobytes_per_sec);
134+
vSamplesOut.push_front(out_rate_kilobytes_per_sec);
135135
nLastBytesIn = bytesIn;
136136
nLastBytesOut = bytesOut;
137137

0 commit comments

Comments
 (0)