aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/qt/bitcoinunits.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp
index 9df05d2a13..1f9792a112 100644
--- a/src/qt/bitcoinunits.cpp
+++ b/src/qt/bitcoinunits.cpp
@@ -100,9 +100,7 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
int num_decimals = decimals(unit);
qint64 n_abs = (n > 0 ? n : -n);
qint64 quotient = n_abs / coin;
- qint64 remainder = n_abs % coin;
QString quotient_str = QString::number(quotient);
- QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0');
// Use SI-style thin space separators as these are locale independent and can't be
// confused with the decimal marker.
@@ -116,7 +114,14 @@ QString BitcoinUnits::format(int unit, const CAmount& nIn, bool fPlus, Separator
quotient_str.insert(0, '-');
else if (fPlus && n > 0)
quotient_str.insert(0, '+');
- return quotient_str + QString(".") + remainder_str;
+
+ if (num_decimals > 0) {
+ qint64 remainder = n_abs % coin;
+ QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0');
+ return quotient_str + QString(".") + remainder_str;
+ } else {
+ return quotient_str;
+ }
}