ktongue's picture
download
raw
669 Bytes
import {formatDecimalParts} from "./formatDecimal.js";
export var prefixExponent;
export default function(x, p) {
var d = formatDecimalParts(x, p);
if (!d) return prefixExponent = undefined, x.toPrecision(p);
var coefficient = d[0],
exponent = d[1],
i = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1,
n = coefficient.length;
return i === n ? coefficient
: i > n ? coefficient + new Array(i - n + 1).join("0")
: i > 0 ? coefficient.slice(0, i) + "." + coefficient.slice(i)
: "0." + new Array(1 - i).join("0") + formatDecimalParts(x, Math.max(0, p + i - 1))[0]; // less than 1y!
}

Xet Storage Details

Size:
669 Bytes
·
Xet hash:
74cc21689ceb10e9b028ee2f78690e0abaed9f1b857639547f8146207eac769d

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.