|
|
|
!function(n){"use strict";function e(n){var e,i,t,r=n.length-1,s="",o=n[0];if(r>0){for(s+=o,e=1;r>e;e++)t=n[e]+"",i=Un-t.length,i&&(s+=l(i)),s+=t;o=n[e],t=o+"",i=Un-t.length,i&&(s+=l(i))}else if(0===o)return"0";for(;o%10===0;)o/=10;return s+o}function i(n,e,i){if(n!==~~n||e>n||n>i)throw Error(On+n)}function t(n,e,i,t){var r,s,o,u;for(s=n[0];s>=10;s/=10)--e;return--e<0?(e+=Un,r=0):(r=Math.ceil((e+1)/Un),e%=Un),s=Dn(10,Un-e),u=n[r]%s|0,null==t?3>e?(0==e?u=u/100|0:1==e&&(u=u/10|0),o=4>i&&99999==u||i>3&&49999==u||5e4==u||0==u):o=(4>i&&u+1==s||i>3&&u+1==s/2)&&(n[r+1]/s/100|0)==Dn(10,e-2)-1||(u==s/2||0==u)&&0==(n[r+1]/s/100|0):4>e?(0==e?u=u/1e3|0:1==e?u=u/100|0:2==e&&(u=u/10|0),o=(t||4>i)&&9999==u||!t&&i>3&&4999==u):o=((t||4>i)&&u+1==s||!t&&i>3&&u+1==s/2)&&(n[r+1]/s/1e3|0)==Dn(10,e-3)-1,o}function r(n,e,i){for(var t,r,s=[0],o=0,u=n.length;u>o;){for(r=s.length;r--;)s[r]*=e;for(s[0]+=Nn.indexOf(n.charAt(o++)),t=0;t<s.length;t++)s[t]>i-1&&(void 0===s[t+1]&&(s[t+1]=0),s[t+1]+=s[t]/i|0,s[t]%=i)}return s.reverse()}function s(n,e){var i,t,r=e.d.length;32>r?(i=Math.ceil(r/3),t=Math.pow(4,-i).toString()):(i=16,t="2.3283064365386962890625e-10"),n.precision+=i,e=E(n,1,e.times(t),new n(wn));for(var s=i;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(wn)}return n.precision-=i,e}function o(n,e,i,t){var r,s,o,u,c,f,h,a,l,d=n.constructor;n:if(null!=e){if(a=n.d,!a)return n;for(r=1,u=a[0];u>=10;u/=10)r++;if(s=e-r,0>s)s+=Un,o=e,h=a[l=0],c=h/Dn(10,r-o-1)%10|0;else if(l=Math.ceil((s+1)/Un),u=a.length,l>=u){if(!t)break n;for(;u++<=l;)a.push(0);h=c=0,r=1,s%=Un,o=s-Un+1}else{for(h=u=a[l],r=1;u>=10;u/=10)r++;s%=Un,o=s-Un+r,c=0>o?0:Fn(h/Dn(10,r-o-1)%10)}if(t=t||0>e||void 0!==a[l+1]||(0>o?h:h%Dn(10,r-o-1)),f=4>i?(c||t)&&(0==i||i==(n.s<0?3:2)):c>5||5==c&&(4==i||t||6==i&&(s>0?o>0?h/Dn(10,r-o):0:a[l-1])%10&1||i==(n.s<0?8:7)),1>e||!a[0])return a.length=0,f?(e-=n.e+1,a[0]=Dn(10,(Un-e%Un)%Un),n.e=-e||0):a[0]=n.e=0,n;if(0==s?(a.length=l,u=1,l--):(a.length=l+1,u=Dn(10,Un-s),a[l]=o>0?(h/Dn(10,r-o)%Dn(10,o)|0)*u:0),f)for(;;){if(0==l){for(s=1,o=a[0];o>=10;o/=10)s++;for(o=a[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(n.e++,a[0]==Ln&&(a[0]=1));break}if(a[l]+=u,a[l]!=Ln)break;a[l--]=0,u=1}for(s=a.length;0===a[--s];)a.pop()}return yn&&(n.e>d.maxE?(n.d=null,n.e=NaN):n.e<d.minE&&(n.e=0,n.d=[0])),n}function u(n,i,t){if(!n.isFinite())return v(n);var r,s=n.e,o=e(n.d),u=o.length;return i?(t&&(r=t-u)>0?o=o.charAt(0)+"."+o.slice(1)+l(r):u>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(n.e<0?"e":"e+")+n.e):0>s?(o="0."+l(-s-1)+o,t&&(r=t-u)>0&&(o+=l(r))):s>=u?(o+=l(s+1-u),t&&(r=t-s-1)>0&&(o=o+"."+l(r))):((r=s+1)<u&&(o=o.slice(0,r)+"."+o.slice(r)),t&&(r=t-u)>0&&(s+1===u&&(o+="."),o+=l(r))),o}function c(n,e){for(var i=1,t=n[0];t>=10;t/=10)i++;return i+e*Un-1}function f(n,e,i){if(e>kn)throw yn=!0,i&&(n.precision=i),Error(qn);return o(new n(xn),e,1,!0)}function h(n,e,i){if(e>Tn)throw Error(qn);return o(new n(bn),e,i,!0)}function a(n){var e=n.length-1,i=e*Un+1;if(e=n[e]){for(;e%10==0;e/=10)i--;for(e=n[0];e>=10;e/=10)i++}return i}function l(n){for(var e="";n--;)e+="0";return e}function d(n,e,i,t){var r,s=new n(wn),o=Math.ceil(t/Un+4);for(yn=!1;;){if(i%2&&(s=s.times(e),A(s.d,o)&&(r=!0)),i=Fn(i/2),0===i){i=s.d.length-1,r&&0===s.d[i]&&++s.d[i];break}e=e.times(e),A(e.d,o)}return yn=!0,s}function g(n){return 1&n.d[n.d.length-1]}function p(n,e,i){for(var t,r=new n(e[0]),s=0;++s<e.length;){if(t=new n(e[s]),!t.s){r=t;break}r[i](t)&&(r=t)}return r}function w(n,i){var r,s,u,c,f,h,a,l=0,d=0,g=0,p=n.constructor,w=p.rounding,m=p.precision;if(!n.d||!n.d[0]||n.e>17)return new p(n.d?n.d[0]?n.s<0?0:1/0:wn:n.s?n.s<0?0:n:NaN);for(null==i?(yn=!1,a=m):a=i,h=new p(.03125);n.e>-2;)n=n.times(h),g+=5;for(s=Math.log(Dn(2,g))/Math.LN10*2+5|0,a+=s,r=c=f=new p(wn),p.precision=a;;){if(c=o(c.times(n),a,1),r=r.times(++d),h=f.plus(In(c,r,a,1)),e(h.d).slice(0,a)===e(f.d).slice(0,a)){for(u=g;u--;)f=o(f.times(f),a,1);if(null!=i)return p.precision=m,f;if(!(3>l&&t(f.d,a-s,w,l)))return o(f,p.precision=m,w,yn=!0);p.precision=a+=10,r=c=h=new p(wn),d=0,l++}f=h}}function m(n,i){var r,s,u,c,h,a,l,d,g,p,w,v=1,N=10,x=n,b=x.d,E=x.constru
|
|
|
|
i(w,m>F?D:S,m,f))):(0==d&&(h=d=1),w=S.slice()),m=w.length,b>m&&w.unshift(0),i(x,w,b,f),-1==h&&(b=x.length,h=e(S,x,F,b),1>h&&(d++,i(x,b>F?D:S,b,f))),b=x.length):0===h&&(d++,x=[0]),N[l++]=d,h&&x[0]?x[b++]=R[A]||0:(x=[R[A]],b=1);while((A++<O||void 0!==x[0])&&M--);p=void 0!==x[0]}N[0]||N.shift()}if(1==g)v.e=a,ln=p;else{for(l=1,d=N[0];d>=10;d/=10)l++;v.e=l+a*g-1,o(v,c?s+v.e+1:s,u,p)}return v}}();if(En=I(En),pn=new En(.5),wn=new En(1),xn=new En(xn),bn=new En(bn),"function"==typeof define&&define.amd)define(function(){return En});else if("undefined"!=typeof module&&module.exports){if(module.exports=En,!Mn)try{Mn=require("crypto")}catch(Hn){}}else n||(n="undefined"!=typeof self&&self&&self.self==self?self:Function("return this")()),dn=n.Decimal,En.noConflict=function(){return n.Decimal=dn,En},n.Decimal=En}(this);
|