From 7a5e04ba53d2da21f95ce5164ae6d47d3ed2adb3 Mon Sep 17 00:00:00 2001 From: encryptedDegen Date: Mon, 28 Oct 2024 16:16:37 +0100 Subject: [PATCH] fix leaderboard rounding function --- src/utils/formatNumber.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/utils/formatNumber.ts b/src/utils/formatNumber.ts index 8f33aee4..1928ac99 100644 --- a/src/utils/formatNumber.ts +++ b/src/utils/formatNumber.ts @@ -4,19 +4,23 @@ export const formatNumber = (number: number) => { return formattedNumber } -export const formatNumberLeaderboard = (num: number) => { - const number = Math.floor(num * 10) / 10 +export const formatNumberLeaderboard = (number: number) => { if (number >= 1e9) return `${(number / 1e9).toLocaleString(navigator.language, { - maximumFractionDigits: 1 + maximumFractionDigits: 1, + roundingMode: 'floor' })}B` if (number >= 1e6) return `${(number / 1e6).toLocaleString(navigator.language, { - maximumFractionDigits: 1 + maximumFractionDigits: 1, + roundingMode: 'floor' })}M` if (number >= 1e3) return `${(number / 1e3).toLocaleString(navigator.language, { - maximumFractionDigits: 1 + maximumFractionDigits: 1, + roundingMode: 'floor' })}k` - return num.toString() + + return number.toString() } +