From d522775b80985c51ca8733849a785d74af8a9316 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Fri, 22 Feb 2019 23:04:02 +0000 Subject: [PATCH] Bugfix: GUI: Ensure negative symbol is before whole number in GUIUtil::formatAssetAmount Fixes: https://github.com/greenaddress/elements/issues/5 --- src/qt/guiutil.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index c3d984fb8b..27f714de7f 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -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')); }