digit.js 1.1 KB

12
  1. "use strict";const g=require("../../../../common/vendor.js");function d(t,n=15){return+parseFloat(Number(t).toPrecision(n))}function u(t){const n=t.toString().split(/[eE]/),e=(n[0].split(".")[1]||"").length-+(n[1]||0);return e>0?e:0}function s(t){if(t.toString().indexOf("e")===-1)return Number(t.toString().replace(".",""));const n=u(t);return n>0?d(Number(t)*Math.pow(10,n)):Number(t)}function f(t){(t>Number.MAX_SAFE_INTEGER||t<Number.MIN_SAFE_INTEGER)&&g.index.__f__("warn","at uni_modules/uview-plus/libs/function/digit.js:45",`${t} 超出了精度限制,结果可能不正确`)}function l(t,n){const[e,r,...o]=t;let i=n(e,r);return o.forEach(c=>{i=n(i,c)}),i}function a(...t){if(t.length>2)return l(t,a);const[n,e]=t,r=s(n),o=s(e),i=u(n)+u(e),c=r*o;return f(c),c/Math.pow(10,i)}function h(...t){if(t.length>2)return l(t,h);const[n,e]=t,r=s(n),o=s(e);return f(r),f(o),a(r/o,d(Math.pow(10,u(e)-u(n))))}function p(t,n){const e=Math.pow(10,n);let r=h(Math.round(Math.abs(a(t,e))),e);return t<0&&r!==0&&(r=a(r,-1)),r}exports.round=p;
  2. //# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/uview-plus/libs/function/digit.js.map