Skip to content

Commit 198fff8

Browse files
committed
GUI: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format
1 parent 831675c commit 198fff8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/qt/bitcoinunits.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include <cassert>
1010

11+
static constexpr auto MAX_DIGITS_BTC = 16;
12+
1113
BitcoinUnits::BitcoinUnits(QObject *parent):
1214
QAbstractListModel(parent),
1315
unitlist(availableUnits())
@@ -108,7 +110,9 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
108110
qint64 n_abs = (n > 0 ? n : -n);
109111
qint64 quotient = n_abs / coin;
110112
QString quotient_str = QString::number(quotient);
111-
if (justify) quotient_str = quotient_str.rightJustified(16 - num_decimals, ' ');
113+
if (justify) {
114+
quotient_str = quotient_str.rightJustified(MAX_DIGITS_BTC - num_decimals, ' ');
115+
}
112116

113117
// Use SI-style thin space separators as these are locale independent and can't be
114118
// confused with the decimal marker.

0 commit comments

Comments
 (0)