1 Commits

Author SHA1 Message Date
Alexander Whitestone
b9ca3b6253 feat: integrate spellf() number formatting into fmt() for numbers >= 1e36 2026-04-08 21:03:43 -04:00

View File

@@ -685,6 +685,7 @@ function fmt(n) {
if (n < 0) return '-' + fmt(-n);
if (n < 1000) return Math.floor(n).toLocaleString();
const scale = Math.floor(Math.log10(n) / 3);
if (scale >= 12) return spellf(n);
if (scale >= NUMBER_ABBREVS.length) return n.toExponential(2);
const abbrev = NUMBER_ABBREVS[scale];
return (n / Math.pow(10, scale * 3)).toFixed(1) + abbrev;