Bugfix: GUI: Ensure negative symbol is before whole number in GUIUtil::formatAssetAmount

Fixes: https://github.com/greenaddress/elements/issues/5
This commit is contained in:
Luke Dashjr 2019-02-22 23:04:02 +00:00 committed by Gregory Sanders
parent 36ebb131dc
commit d522775b80

View file

@ -788,9 +788,13 @@ QString formatAssetAmount(const CAsset& asset, const CAmount& amount, const int
}
}
qlonglong whole = amount / 100000000;
qlonglong fraction = amount % 100000000;
qlonglong abs = qAbs(amount);
qlonglong whole = abs / 100000000;
qlonglong fraction = abs % 100000000;
QString str = QString("%1").arg(whole);
if (amount < 0) {
str.insert(0, '-');
}
if (fraction) {
str += QString(".%1").arg(fraction, 8, 10, QLatin1Char('0'));
}