Improved regularFormat on small numbers

This commit is contained in:
thepaperpilot 2022-05-20 16:50:19 -05:00
parent 3f10abbb09
commit 65e265768b

View file

@ -48,7 +48,10 @@ export function regularFormat(num: DecimalSource, precision: number): string {
return (0).toFixed(precision);
}
if (num.mag < 0.1 && precision !== 0) {
precision = Math.max(Math.max(precision, 4), projInfo.defaultDecimalsShown);
precision = Math.max(
Math.max(precision, num.log10().negate().ceil().toNumber()),
projInfo.defaultDecimalsShown
);
}
return num.toStringWithDecimalPlaces(precision);
}