Four significant digits
64-bitPrints a result with 4 significant digits.
toPrecision(4); toExponential(3) when |v| ≥ 1e5 or 0 < |v| < 1e-3
The text is rounded to 4 digits and converted back with a unary plus to drop trailing zeros. The value is not stored.
/** 4 significant figures, plain. */
export const sig = (v) => (Number.isFinite(v) ? (Math.abs(v) >= 1e5 || (Math.abs(v) < 1e-3 && v !== 0) ? v.toExponential(3) : String(+v.toPrecision(4))) : '');