Skip to content

Commit

Permalink
Merge pull request #790 from invariant-labs/remove-leftover-dot
Browse files Browse the repository at this point in the history
fix lefover dot in format number
  • Loading branch information
p6te authored Nov 22, 2024
2 parents b0706d3 + bc747bd commit 0b63313
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1537,14 +1537,18 @@ export const formatNumber = (
? String(parseInt(afterDot)).slice(0, decimalsAfterDot)
: afterDot

formattedNumber =
beforeDot +
'.' +
(parsedAfterDot
? leadingZeros > decimalsAfterDot
? '0' + printSubNumber(leadingZeros) + trimZeros(parsedAfterDot)
: trimZeros(parsedAfterDot)
: '')
if (parsedAfterDot) {
formattedNumber =
beforeDot +
'.' +
(parsedAfterDot
? leadingZeros > decimalsAfterDot
? '0' + printSubNumber(leadingZeros) + trimZeros(parsedAfterDot)
: trimZeros(parsedAfterDot)
: '')
} else {
formattedNumber = beforeDot
}
}

return isNegative ? '-' + formattedNumber : formattedNumber
Expand Down

0 comments on commit 0b63313

Please sign in to comment.