Skip to content

Commit

Permalink
fix: fix rounding to show the first significant digit
Browse files Browse the repository at this point in the history
  • Loading branch information
MindFreeze committed May 3, 2024
1 parent 0ab65d8 commit 0e5d154
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ export function formatState(state: number, round: number, locale: FrontendLocale
} while (/^[0\.]*$/.test(rounded) && decimals < 100);

if (!monetary_unit) {
return formatNumber(parseFloat(rounded), locale);
return formatNumber(parseFloat(rounded), locale, {
maximumFractionDigits: decimals-1,
});
} else {
return formatNumber(parseFloat(rounded), locale, {
style: "currency",
currency: monetary_unit,
minimumFractionDigits: round,
minimumFractionDigits: decimals-1,
});
}
}
Expand Down

0 comments on commit 0e5d154

Please sign in to comment.