Skip to content

Commit

Permalink
limit decimals on large numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
smk762 committed Aug 12, 2024
1 parent 92b39a5 commit fb1f352
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
9 changes: 9 additions & 0 deletions atomic_defi_design/Dex/Constants/General.qml
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ QtObject {
return feetype + " " + amount + " " + ticker + " (" + fiat_text + ")"
}

function reducedBignum(text, decimals=8, max_length=12) {
let val = new BigNumber(text).toFixed(decimals)
if (val.length > max_length)
{
return val.substring(0, max_length) + "..."
}
return val
}

function getSimpleFromPlaceholder(selectedTicker, selectedOrder, sell_ticker_balance) {
if (sell_ticker_balance == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Item
Layout.fillHeight: true
Layout.minimumWidth: 90
Layout.alignment: Qt.AlignVCenter
text: { new BigNumber(price).toFixed(8) }
text: General.reducedBignum(price)
font.family: DexTypo.fontFamily
font.pixelSize: 12
color: isAsk ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor
Expand All @@ -200,7 +200,7 @@ Item
Layout.fillHeight: true
Layout.minimumWidth: 90
Layout.alignment: Qt.AlignVCenter
text: { new BigNumber(base_max_volume).toFixed(6) }
text: General.reducedBignum(base_max_volume)
font.family: DexTypo.fontFamily
font.pixelSize: 12
horizontalAlignment: Text.AlignRight
Expand All @@ -219,7 +219,7 @@ Item
Layout.alignment: Qt.AlignVCenter
font.family: DexTypo.fontFamily
font.pixelSize: 12
text: { new BigNumber(total).toFixed(6) }
text: General.reducedBignum(total)
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
wrapMode: Text.NoWrap
Expand Down

0 comments on commit fb1f352

Please sign in to comment.