Skip to content

Commit

Permalink
Merge #153: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::f…
Browse files Browse the repository at this point in the history
…ormat

198fff8 GUI: Define MAX_DIGITS_BTC for magic number in BitcoinUnits::format (Luke Dashjr)

Pull request description:

  A magic number snuck in with bitcoin/bitcoin#16432

ACKs for top commit:
  hebasto:
    ACK 198fff8, I have reviewed the code and it looks OK, I agree it can be merged.
  kristapsk:
    utACK 198fff8

Tree-SHA512: 78dc23c2ae61bac41e5e34eebf57274599cb2ebb0b18d46e8a3228d42b256a1bc9bb17091c748f0f692ef1c4c241cfbd3e30a12bcd12222a234c1a9547ebe786
  • Loading branch information
MarcoFalke committed Dec 17, 2020
2 parents 83abd6b + 198fff8 commit d0e76b5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/qt/bitcoinunits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#include <cassert>

static constexpr auto MAX_DIGITS_BTC = 16;

BitcoinUnits::BitcoinUnits(QObject *parent):
QAbstractListModel(parent),
unitlist(availableUnits())
Expand Down Expand Up @@ -108,7 +110,9 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
qint64 n_abs = (n > 0 ? n : -n);
qint64 quotient = n_abs / coin;
QString quotient_str = QString::number(quotient);
if (justify) quotient_str = quotient_str.rightJustified(16 - num_decimals, ' ');
if (justify) {
quotient_str = quotient_str.rightJustified(MAX_DIGITS_BTC - num_decimals, ' ');
}

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

0 comments on commit d0e76b5

Please sign in to comment.