1 |
- "use strict";function strip(t,e){return void 0===e&&(e=12),+parseFloat(t.toPrecision(e))}function digitLength(t){t=t.toString().split(/[eE]/),t=(t[0].split(".")[1]||"").length-+(t[1]||0);return 0<t?t:0}function float2Fixed(t){var e;return-1===t.toString().indexOf("e")?Number(t.toString().replace(".","")):0<(e=digitLength(t))?strip(t*Math.pow(10,e)):t}function checkBoundary(t){_boundaryCheckingState&&(t>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER)&&console.warn(t+" is beyond boundary when transfer to integer, the results may not be accurate")}function times(t,e){for(var i,n,o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];return 0<o.length?times.apply(void 0,[times(t,e),o[0]].concat(o.slice(1))):(i=float2Fixed(t),n=float2Fixed(e),t=digitLength(t)+digitLength(e),checkBoundary(e=i*n),e/Math.pow(10,t))}function plus(t,e){for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];return 0<i.length?plus.apply(void 0,[plus(t,e),i[0]].concat(i.slice(1))):(times(t,t=Math.pow(10,Math.max(digitLength(t),digitLength(e))))+times(e,t))/t}function minus(t,e){for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];return 0<i.length?minus.apply(void 0,[minus(t,e),i[0]].concat(i.slice(1))):(times(t,t=Math.pow(10,Math.max(digitLength(t),digitLength(e))))-times(e,t))/t}function divide(t,e){for(var i,n,o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];return 0<o.length?divide.apply(void 0,[divide(t,e),o[0]].concat(o.slice(1))):(i=float2Fixed(t),n=float2Fixed(e),checkBoundary(i),checkBoundary(n),times(i/n,Math.pow(10,digitLength(e)-digitLength(t))))}function round(t,e){e=Math.pow(10,e);return divide(Math.round(times(t,e)),e)}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0,Object.defineProperty(exports,"__esModule",{value:!0});var _boundaryCheckingState=!0;function enableBoundaryChecking(t){_boundaryCheckingState=t=void 0===t?!0:t}var index={strip:strip,plus:plus,minus:minus,times:times,divide:divide,round:round,digitLength:digitLength,float2Fixed:float2Fixed,enableBoundaryChecking:enableBoundaryChecking},_default=exports.default=index;
|