fix number formatting

This commit is contained in:
saml33 2023-11-02 23:01:34 +11:00
parent f39a123dbf
commit bb2b0201a7
1 changed files with 3 additions and 2 deletions

View File

@ -145,10 +145,11 @@ const usdFormatter3Sig = Intl.NumberFormat('en', {
})
export const countLeadingZeros = (x: number) => {
if (x % 1 == 0) {
const absoluteX = Math.abs(x)
if (absoluteX % 1 == 0) {
return 0
} else {
return -1 - Math.floor(Math.log10(x % 1))
return -1 - Math.floor(Math.log10(absoluteX % 1))
}
}