Skip to content

Commit

Permalink
billion number supported
Browse files Browse the repository at this point in the history
  • Loading branch information
mnsrulz committed Aug 20, 2024
1 parent c991ebf commit 579688d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/formatters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ export const fixedCurrencyFormatter = new Intl.NumberFormat('en-US', { style: 'c

export const humanAbsCurrencyFormatter = (tick: number) => {
tick = Math.abs(tick);
if (tick >= 1000000) {
if (tick >= 1000000000) {
return `${(tick / 1000000000).toFixed(1)}B`; // Billions
} else if (tick >= 1000000) {
return `${(tick / 1000000).toFixed(1)}M`; // Millions
} else if (tick >= 1000) {
return `${(tick / 1000).toFixed(1)}K`; // Thousands
Expand Down

0 comments on commit 579688d

Please sign in to comment.