mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 04:35:46 +01:00
MISC: Update formatHashes function (#1252)
When hash/hashRate value is too small, formatHashes converts it to the useless string 0.000. This PR fixes that.
This commit is contained in:
parent
309cd55085
commit
2414949c2c
@ -148,7 +148,18 @@ export const formatFavor = formatNumberNoSuffix;
|
||||
/** Standard noninteger formatting with no options set. Collapses to suffix at 1000 and shows 3 fractional digits. */
|
||||
export const formatBigNumber = (n: number) => formatNumber(n);
|
||||
export const formatExp = formatBigNumber;
|
||||
export const formatHashes = formatBigNumber;
|
||||
export const formatHashes = (n: number) => {
|
||||
if (n < 0.00001) {
|
||||
return formatNumber(n, 8);
|
||||
}
|
||||
if (n < 0.001) {
|
||||
return formatNumber(n, 6);
|
||||
}
|
||||
if (n < 0.01) {
|
||||
return formatNumber(n, 4);
|
||||
}
|
||||
return formatNumber(n);
|
||||
};
|
||||
export const formatReputation = formatBigNumber;
|
||||
export const formatPopulation = formatBigNumber;
|
||||
export const formatSecurity = formatBigNumber;
|
||||
|
Loading…
Reference in New Issue
Block a user