UI: Use exponential notation when formatting very small HP or thread values (#2656)

This commit is contained in:
catloversg
2026-04-13 06:49:30 +07:00
committed by GitHub
parent fb3fa00b3d
commit cc9144c01b

View File

@@ -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 */