diff --git a/src/ui/formatNumber.ts b/src/ui/formatNumber.ts index 724d478b2..15348f60d 100644 --- a/src/ui/formatNumber.ts +++ b/src/ui/formatNumber.ts @@ -113,8 +113,11 @@ export function formatNumber(n: number, fractionalDigits = 3, suffixStart = 1000 // Special handling for Infinities if (nAbs === Infinity) return n < 0 ? "-∞" : "∞"; + if (suffixStart < 1000) { + throw new Error("suffixStart must be greater than or equal to 1000"); + } - // Early return for non-suffix + // Early return for non-suffix or if number and suffix are 0 if (nAbs < suffixStart) { if (isInteger) return basicFormatter.format(n); return getFormatter(fractionalDigits).format(n);