|
|
|
/*! decimal.js v7.2.1 https://github.com/MikeMcl/decimal.js/LICENCE */(function(e){"use strict";function k(e){var t,n,r,i=e.length-1,s="",o=e[0];if(i>0){s+=o;for(t=1;t<i;t++)r=e[t]+"",n=S-r.length,n&&(s+=I(n)),s+=r;o=e[t],r=o+"",n=S-r.length,n&&(s+=I(n))}else if(o===0)return"0";for(;o%10===0;)o/=10;return s+o}function L(e,t,n){if(e!==~~e||e<t||e>n)throw Error(h+e)}function A(e,t,n,r){var i,s,o,u;for(s=e[0];s>=10;s/=10)--t;return--t<0?(t+=S,i=0):(i=Math.ceil((t+1)/S),t%=S),s=m(10,S-t),u=e[i]%s|0,r==null?t<3?(t==0?u=u/100|0:t==1&&(u=u/10|0),o=n<4&&u==99999||n>3&&u==49999||u==5e4||u==0):o=(n<4&&u+1==s||n>3&&u+1==s/2)&&(e[i+1]/s/100|0)==m(10,t-2)-1||(u==s/2||u==0)&&(e[i+1]/s/100|0)==0:t<4?(t==0?u=u/1e3|0:t==1?u=u/100|0:t==2&&(u=u/10|0),o=(r||n<4)&&u==9999||!r&&n>3&&u==4999):o=((r||n<4)&&u+1==s||!r&&n>3&&u+1==s/2)&&(e[i+1]/s/1e3|0)==m(10,t-3)-1,o}function O(e,t,n){var i,s=[0],o,u=0,a=e.length;for(;u<a;){for(o=s.length;o--;)s[o]*=t;s[0]+=r.indexOf(e.charAt(u++));for(i=0;i<s.length;i++)s[i]>n-1&&(s[i+1]===void 0&&(s[i+1]=0),s[i+1]+=s[i]/n|0,s[i]%=n)}return s.reverse()}function M(e,t){var n,r,i=t.d.length;i<32?(n=Math.ceil(i/3),r=Math.pow(4,-n).toString()):(n=16,r="2.3283064365386962890625e-10"),e.precision+=n,t=K(e,1,t.times(r),new e(1));for(var s=n;s--;){var o=t.times(t);t=o.times(o).minus(o).times(8).plus(1)}return e.precision-=n,t}function D(e,t,n,r){var i,s,o,u,a,f,c,h,p,d=e.constructor;e:if(t!=null){h=e.d;if(!h)return e;for(i=1,u=h[0];u>=10;u/=10)i++;s=t-i;if(s<0)s+=S,o=t,c=h[p=0],a=c/m(10,i-o-1)%10|0;else{p=Math.ceil((s+1)/S),u=h.length;if(p>=u){if(!r)break e;for(;u++<=p;)h.push(0);c=a=0,i=1,s%=S,o=s-S+1}else{c=u=h[p];for(i=1;u>=10;u/=10)i++;s%=S,o=s-S+i,a=o<0?0:c/m(10,i-o-1)%10|0}}r=r||t<0||h[p+1]!==void 0||(o<0?c:c%m(10,i-o-1)),f=n<4?(a||r)&&(n==0||n==(e.s<0?3:2)):a>5||a==5&&(n==4||r||n==6&&(s>0?o>0?c/m(10,i-o):0:h[p-1])%10&1||n==(e.s<0?8:7));if(t<1||!h[0])return h.length=0,f?(t-=e.e+1,h[0]=m(10,(S-t%S)%S),e.e=-t||0):h[0]=e.e=0,e;s==0?(h.length=p,u=1,p--):(h.length=p+1,u=m(10,S-s),h[p]=o>0?(c/m(10,i-o)%m(10,o)|0)*u:0);if(f)for(;;){if(p==0){for(s=1,o=h[0];o>=10;o/=10)s++;o=h[0]+=u;for(u=1;o>=10;o/=10)u++;s!=u&&(e.e++,h[0]==E&&(h[0]=1));break}h[p]+=u;if(h[p]!=E)break;h[p--]=0,u=1}for(s=h.length;h[--s]===0;)h.pop()}return l&&(e.e>d.maxE?(e.d=null,e.e=NaN):e.e<d.minE&&(e.e=0,e.d=[0])),e}function P(e,t,n){if(!e.isFinite())return X(e);var r,i=e.e,s=k(e.d),o=s.length;return t?(n&&(r=n-o)>0?s=s.charAt(0)+"."+s.slice(1)+I(r):o>1&&(s=s.charAt(0)+"."+s.slice(1)),s=s+(e.e<0?"e":"e+")+e.e):i<0?(s="0."+I(-i-1)+s,n&&(r=n-o)>0&&(s+=I(r))):i>=o?(s+=I(i+1-o),n&&(r=n-i-1)>0&&(s=s+"."+I(r))):((r=i+1)<o&&(s=s.slice(0,r)+"."+s.slice(r)),n&&(r=n-o)>0&&(i+1===o&&(s+="."),s+=I(r))),s}function H(e,t){var n=e[0];for(t*=S;n>=10;n/=10)t++;return t}function B(e,t,n){if(t>T)throw l=!0,n&&(e.precision=n),Error(p);return D(new e(i),t,1,!0)}function j(e,t,n){if(t>N)throw Error(p);return D(new e(s),t,n,!0)}function F(e){var t=e.length-1,n=t*S+1;t=e[t];if(t){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function I(e){var t="";for(;e--;)t+="0";return t}function q(e,t,n,r){var i,s=new e(1),o=Math.ceil(r/S+4);l=!1;for(;;){n%2&&(s=s.times(t),Y(s.d,o)&&(i=!0)),n=v(n/2);if(n===0){n=s.d.length-1,i&&s.d[n]===0&&++s.d[n];break}t=t.times(t),Y(t.d,o)}return l=!0,s}function R(e){return e.d[e.d.length-1]&1}function U(e,t,n){var r,i=new e(t[0]),s=0;for(;++s<t.length;){r=new e(t[s]);if(!r.s){i=r;break}i[n](r)&&(i=r)}return i}function z(e,t){var n,r,i,s,o,u,a,f=0,c=0,h=0,p=e.constructor,d=p.rounding,v=p.precision;if(!e.d||!e.d[0]||e.e>17)return new p(e.d?e.d[0]?e.s<0?0:1/0:1:e.s?e.s<0?0:e:0/0);t==null?(l=!1,a=v):a=t,u=new p(.03125);while(e.e>-2)e=e.times(u),h+=5;r=Math.log(m(2,h))/Math.LN10*2+5|0,a+=r,n=s=o=new p(1),p.precision=a;for(;;){s=D(s.times(e),a,1),n=n.times(++c),u=o.plus(_(s,n,a,1));if(k(u.d).slice(0,a)===k(o.d).slice(0,a)){i=h;while(i--)o=D(o.times(o),a,1);if(t!=null)return p.precision=v,o;if(!(f<3&&A(o.d,a-r,d,f)))return D(o,p.precision=v,d,l=!0);p.precision=a+=10,n=s=u=new p(1),c=0,f++}o=u}}function W(e,t){var n,r,i,s,o,u,a,f,c,h,p,d=1,v=10,m=e
|