mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
UI: Use exponential notation when formatting very small HP or thread values (#2656)
This commit is contained in:
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user