UNPKG

round-decimal

Version:
2 lines (1 loc) 515 B
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});function a(t){return Math.pow(2,Math.ceil(Math.log2(Math.abs(t)))-52)}function o(t){return Math.trunc(Math.abs(Math.log10(a(t))))}const r=3;function e(t,c=r){const i=o(t);if(i<c)return t;const n=t<0?-Math.pow(10,i):Math.pow(10,i);return Math.round(t*n)/n}exports.approximateUlp=a;exports.default=e;exports.defaultMinSignificantFractionDigits=r;exports.getSignificantFractionDigits=o;exports.roundDecimal=e;