diff --git a/src/ui/formatNumber.ts b/src/ui/formatNumber.ts index 5a04cdbf4..5011d6c71 100644 --- a/src/ui/formatNumber.ts +++ b/src/ui/formatNumber.ts @@ -193,8 +193,18 @@ export const formatInt = (n: number) => formatNumber(n, 3, 1000, true); export const formatSleeveMemory = formatInt; export const formatShares = formatInt; -/** Display an integer up to 999,999 before collapsing to suffixed form with 3 fractional digits */ -export const formatHp = (n: number) => formatNumber(n, 3, 1e6, true); +/** + * Format a number using basicFormatter for values below 1e6, and a suffixed form with up to 3 fractional digits for + * values at or above 1e6. This uses formatNumber, so check that function for nuanced details. + * + * Values in the range (0, 0.001) are displayed in exponential notation. + */ +export const formatHp = (n: number) => { + if (n > 0 && n < 0.001) { + return formatExponential(n); + } + return formatNumber(n, 3, 1e6, true); +}; export const formatThreads = formatHp; /** Display an integer up to 999,999,999 before collapsing to suffixed form with 3 fractional digits */