From bb2b0201a7b2d35e358b78c14f4507a214144c28 Mon Sep 17 00:00:00 2001 From: saml33 Date: Thu, 2 Nov 2023 23:01:34 +1100 Subject: [PATCH] fix number formatting --- utils/numbers.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/numbers.ts b/utils/numbers.ts index 1139ceb8..5943feaf 100644 --- a/utils/numbers.ts +++ b/utils/numbers.ts @@ -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)) } }