handle negative resources in account

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
Arthur Lu 2023-04-25 15:20:59 +00:00
parent bcc7e0ea57
commit 938741d429

View File

@ -49,7 +49,10 @@ function parseNumber(value, unitData) {
let multiplier = unitData.multiplier;
let unit = unitData.unit;
value = multiplier * value;
if (compact) {
if (value <= 0) {
return `0 ${unit}`;
}
else if (compact) {
let exponent = Math.floor(Math.log2(value) / 10);
value = value / 1024 ** exponent;
let unitPrefix = SIPrefix[exponent];