forked from Pseudonian/SynergismOfficial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
break_infinity2.js
8 lines (8 loc) · 45.5 KB
/
break_infinity2.js
1
2
3
4
5
6
7
8
"use strict";
//From Hevipelle's AD - handles larger numbers than I should have ever used
if (!Math.log10) {
Math.log10 = Math.log10 || function(x) {
return Math.log(x) * Math.LOG10E;
};
};function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},padEnd=function(e,t,n){if(null==e||null==t)return e;var r=String(e),i=r.length;if(i>=t)return r;var o=null==n?"":String(n);""===o&&(o=" ");for(var a=t-i;o.length<a;)o+=o;var u=o.length>a?o.substr(0,a):o;return r+u};!function(e){function t(e,t,n,r){this.sign=e,this.magnitude=t,this.length=n,this.value=r}function n(){}for(var r=function(e,t,n,r){for(var i=t-1,o=0,a=10>r?r:10;++i<n;){var u=e.charCodeAt(i),s=u-48;if((0>s||s>=a)&&(s=-55+u,(10>s||s>=r)&&(s=-87+u,10>s||s>=r)))throw new RangeError;o=o*r+s}return o},i=function(e){for(var t=new Array(e),n=-1;++n<e;)t[n]=0;return t},o=function(e,t){for(var n=1,r=e,i=t;i>1;){var o=Math.floor(i/2);2*o!==i&&(n*=r),r*=r,i=o}return n*r},a=2/9007199254740992;1+a/2!==1;)a/=2;for(var u=2/a,s=134217728;2/a>s*s;)s*=2;var f=s+1,l=function(e,t,n){var r=f*e,i=r-(r-e),o=e-i,a=f*t,u=a-(a-t),s=t-u,l=i*u+n+i*s+o*u+o*s;return l},c=function(e){var t=e-u+u;return t>e?t-1:t},h=function(e,t,n){var r=t*n,i=l(t,n,-r),o=c(r/u),a=r-o*u+i;return 0>a&&(a+=u,o-=1),a+=e-u,0>a?a+=u:o+=1,{lo:a,hi:o}},m=function(e,t,n){if(e>=n)throw new RangeError;var r=e*u,i=c(r/n),o=0-l(i,n,-r);0>o&&(i-=1,o+=n),o+=t-n,0>o?o+=n:i+=1;var a=c(o/n);return o-=a*n,i+=a,{q:i,r:o}},p=function(e,n,r,i){return new t(e,n,r,i)};t.parseInt=function(e,t){if(void 0==t&&(t=10),10!==t&&(2>t||t>36||t!==Math.floor(t)))throw new RangeError("radix argument must be an integer between 2 and 36");var n=e.length;if(0===n)throw new RangeError;var a=0,s=e.charCodeAt(0),f=0;if(43===s&&(f=1),45===s&&(f=1,a=1),n-=f,0===n)throw new RangeError;if(o(t,n)<=u){var l=r(e,f,f+n,t);return p(0===l?0:a,void 0,0===l?0:1,l)}for(var m=0,v=1,g=c(u/t);g>=v;)m+=1,v*=t;for(var d=Math.floor((n-1)/m)+1,y=i(d),x=d,N=n;N>0;)x-=1,y[x]=r(e,f+(N>m?N-m:0),f+N,t),N-=m;for(var k=-1;++k<d;){for(var b=y[k],w=-1;++w<k;){var E=h(b,y[w],v),V=E.lo,M=E.hi;y[w]=V,b=M}y[k]=b}for(;d>0&&0===y[d-1];)d-=1;return p(0===d?0:a,y,d,y[0])};var v=function(e,t){if(e.length!==t.length)return e.length<t.length?-1:1;for(var n=e.length;--n>=0;)if((void 0==e.magnitude?e.value:e.magnitude[n])!==(void 0==t.magnitude?t.value:t.magnitude[n]))return(void 0==e.magnitude?e.value:e.magnitude[n])<(void 0==t.magnitude?t.value:t.magnitude[n])?-1:1;return 0};t.prototype.compareTo=function(e){var t=this,n=t.sign===e.sign?v(t,e):1;return 1===t.sign?0-n:n},t.prototype.addAndSubtract=function(e,t){var n=this,r=v(n,e),o=0>r?0!==t?1-e.sign:e.sign:n.sign,a=0>r?n:e,s=0>r?e:n;if(0===a.length)return p(o,s.magnitude,s.length,s.value);var f=0,l=s.length;if(n.sign!==(0!==t?1-e.sign:e.sign)){if(f=1,a.length===l)for(;l>0&&(void 0==a.magnitude?a.value:a.magnitude[l-1])===(void 0==s.magnitude?s.value:s.magnitude[l-1]);)l-=1;if(0===l)return p(0,i(0),0,0)}for(var c=i(l+(1-f)),h=-1,m=0;++h<l;){var g=h<a.length?void 0==a.magnitude?a.value:a.magnitude[h]:0;m+=(void 0==s.magnitude?s.value:s.magnitude[h])+(0!==f?0-g:g-u),0>m?(c[h]=u+m,m=0-f):(c[h]=m,m=1-f)}for(0!==m&&(c[l]=m,l+=1);l>0&&0===c[l-1];)l-=1;return p(o,c,l,c[0])},t.prototype.add=function(e){return this.addAndSubtract(e,0)},t.prototype.subtract=function(e){return this.addAndSubtract(e,1)},t.prototype.multiply=function(e){var t=this;if(0===t.length||0===e.length)return p(0,i(0),0,0);var n=1===t.sign?1-e.sign:e.sign;if(1===t.length&&1===(void 0==t.magnitude?t.value:t.magnitude[0]))return p(n,e.magnitude,e.length,e.value);if(1===e.length&&1===(void 0==e.magnitude?e.value:e.magnitude[0]))return p(n,t.magnitude,t.length,t.value);for(var r=t.length+e.length,o=i(r),a=-1;++a<e.length;){for(var s=0,f=-1;++f<t.length;){var l=0;s+=o[f+a]-u,s>=0?l=1:s+=u;var c=h(s,void 0==t.magnitude?t.value:t.magnitude[f],void 0==e.magnitude?e.value:e.magnitude[a]),m=c.lo,v=c.hi;o[f+a]=m,s=v+l}o[t.length+a]=s}for(;r>0&&0===o[r-1];)r-=1;return p(n,o,r,o[0])},t.prototype.divideAndRemainder=function(e,t){var n=this;if(0===e.length)throw new RangeError;if(0===n.length)return p(0,i(0),0,0);var r=1===n.sign?1-e.sign:e.sign;if(1===e.length&&1===(void 0==e.magnitude?e.value:e.magnitude[0]))return 0!==t?p(r,n.magnitude,n.length,n.value):p(0,i(0),0,0);for(var o=n.length+1,a=i(o+e.length+1),s=a,f=a,l=-1;++l<n.length;)f[l]=void 0==n.magnitude?n.value:n.magnitude[l];for(var v=-1;++v<e.length;)s[o+v]=void 0==e.magnitude?e.value:e.magnitude[v];var g=s[o+e.length-1],d=1;if(e.length>1){if(d=c(u/(g+1)),d>1){for(var y=0,x=-1;++x<o+e.length;){var N=h(y,a[x],d),k=N.lo,b=N.hi;a[x]=k,y=b}a[o+e.length]=y,g=s[o+e.length-1]}if(g<c(u/2))throw new RangeError}var w=n.length-e.length+1;0>w&&(w=0);for(var E=void 0,V=0,M=w;--M>=0;){var I=e.length+M,T=u-1;if(f[I]!==g){var _=m(f[I],f[I-1],g),q=_.q;T=q}for(var S=0,F=0,O=M-1;++O<=I;){var B=f[O],D=h(F,T,s[o+O-M]),R=D.lo,P=D.hi;f[O]=R,F=P,S+=B-f[O],0>S?(f[O]=u+S,S=-1):(f[O]=S,S=0)}for(;0!==S;){T-=1;for(var A=0,C=M-1;++C<=I;)A+=f[C]-u+s[o+C-M],0>A?(f[C]=u+A,A=0):(f[C]=A,A=1);S+=A}0!==t&&0!==T&&(0===V&&(V=M+1,E=i(V)),E[M]=T)}if(0!==t)return 0===V?p(0,i(0),0,0):p(r,E,V,E[0]);var L=n.length+1;if(d>1){for(var H=0,U=L;--U>=0;){var z=m(H,f[U],d),Z=z.q,G=z.r;f[U]=Z,H=G}if(0!==H)throw new RangeError}for(;L>0&&0===f[L-1];)L-=1;if(0===L)return p(0,i(0),0,0);for(var W=i(L),Y=-1;++Y<L;)W[Y]=f[Y];return p(n.sign,W,L,W[0])},t.prototype.divide=function(e){return this.divideAndRemainder(e,1)},t.prototype.remainder=function(e){return this.divideAndRemainder(e,0)},t.prototype.negate=function(){var e=this;return p(0===e.length?e.sign:1-e.sign,e.magnitude,e.length,e.value)},t.prototype.toString=function(e){if(void 0==e&&(e=10),10!==e&&(2>e||e>36||e!==Math.floor(e)))throw new RangeError("radix argument must be an integer between 2 and 36");var t=this,n=1===t.sign?"-":"",r=t.length;if(0===r)return"0";if(1===r)return n+=(void 0==t.magnitude?t.value:t.magnitude[0]).toString(e);for(var o=0,a=1,s=c(u/e);s>=a;)o+=1,a*=e;if(u>=a*e)throw new RangeError;for(var f=r+Math.floor((r-1)/o)+1,l=i(f),h=-1;++h<r;)l[h]=void 0==t.magnitude?t.value:t.magnitude[h];for(var p=f;0!==r;){for(var v=0,g=r;--g>=0;){var d=m(v,l[g],a),y=d.q,x=d.r;l[g]=y,v=x}for(;r>0&&0===l[r-1];)r-=1;p-=1,l[p]=v}for(n+=l[p].toString(e);++p<f;){for(var N=l[p].toString(e),k=o-N.length;--k>=0;)n+="0";n+=N}return n},t.fromNumber=function(e){return p(0>e?1:0,void 0,0===e?0:1,0>e?0-e:0+e)},t.prototype.toNumber=function(){return 0===this.length?0:1===this.length?1===this.sign?0-this.value:this.value:this};var g=function(e,n){try{}catch(r){}return t.parseInt(e,n)},d=function(e){return"number"==typeof e?t.fromNumber(e):e},y=function(e,t){try{}catch(n){}var r=d(e),i=d(t);return r.compareTo(i)},x=function(e){return e.toNumber()},N=function(e,t){try{}catch(n){}var r=d(e),i=d(t);return x(r.add(i))},k=function(e,t){try{}catch(n){}var r=d(e),i=d(t);return x(r.subtract(i))},b=function(e,t){try{}catch(n){}var r=d(e),i=d(t);return x(r.multiply(i))},w=function(e,t){try{}catch(n){}var r=d(e),i=d(t);return x(r.divide(i))},E=function(e,t){try{}catch(n){}var r=d(e),i=d(t);return x(r.remainder(i))},V=function(e){try{}catch(t){}var n=d(e);return x(n.negate())};n.parseInt=function(e,t){if("string"==typeof e&&"number"==typeof t){var n=0+Number.parseInt(e,t);if(n>=-9007199254740991&&9007199254740991>=n)return n}return g(e,t)},n.compareTo=function(e,t){return"number"==typeof e&&"number"==typeof t?t>e?-1:e>t?1:0:y(e,t)},n.add=function(e,t){if("number"==typeof e&&"number"==typeof t){var n=e+t;if(n>=-9007199254740991&&9007199254740991>=n)return n}return N(e,t)},n.subtract=function(e,t){if("number"==typeof e&&"number"==typeof t){var n=e-t;if(n>=-9007199254740991&&9007199254740991>=n)return n}return k(e,t)},n.multiply=function(e,t){if("number"==typeof e&&"number"==typeof t){var n=0+e*t;if(n>=-9007199254740991&&9007199254740991>=n)return n}return b(e,t)},n.divide=function(e,t){return"number"==typeof e&&"number"==typeof t&&0!==t?0===e?0:e>0&&t>0||0>e&&0>t?0+Math.floor(e/t):0-Math.floor((0-e)/t):w(e,t)},n.remainder=function(e,t){return"number"==typeof e&&"number"==typeof t&&0!==t?0+e%t:E(e,t)},n.negate=function(e){return"number"==typeof e?0-e:V(e)},e.BigInteger=n,e.BigIntegerInternal=t}(this),!function(e){function t(e){var t,n,r,i=e.length-1,o="",a=e[0];if(i>0){for(o+=a,t=1;i>t;t++)r=e[t]+"",n=L-r.length,n&&(o+=u(n)),o+=r;a=e[t],r=a+"",n=L-r.length,n&&(o+=u(n))}else if(0===a)return"0";for(;a%10===0;)a/=10;return o+a}function n(e,t,n){if(e!==~~e||t>e||e>n)throw Error(B+e)}function r(e,t,n,r){var i,o,a,u,s,f,l,c,h,m=e.constructor;e:if(null!=t){if(c=e.d,!c)return e;for(i=1,u=c[0];u>=10;u/=10)i++;if(o=t-i,0>o)o+=L,a=t,l=c[h=0],s=l/P(10,i-a-1)%10|0;else if(h=Math.ceil((o+1)/L),u=c.length,h>=u){if(!r)break e;for(;u++<=h;)c.push(0);l=s=0,i=1,o%=L,a=o-L+1}else{for(l=u=c[h],i=1;u>=10;u/=10)i++;o%=L,a=o-L+i,s=0>a?0:l/P(10,i-a-1)%10|0}if(r=r||0>t||void 0!==c[h+1]||(0>a?l:l%P(10,i-a-1)),f=4>n?(s||r)&&(0==n||n==(e.s<0?3:2)):s>5||5==s&&(4==n||r||6==n&&(o>0?a>0?l/P(10,i-a):0:c[h-1])%10&1||n==(e.s<0?8:7)),1>t||!c[0])return c.length=0,f?(t-=e.e+1,c[0]=P(10,(L-t%L)%L),e.e=-t||0):c[0]=e.e=0,e;if(0==o?(c.length=h,u=1,h--):(c.length=h+1,u=P(10,L-o),c[h]=a>0?(l/P(10,i-a)%P(10,a)|0)*u:0),f)for(;;){if(0==h){for(o=1,a=c[0];a>=10;a/=10)o++;for(a=c[0]+=u,u=1;a>=10;a/=10)u++;o!=u&&(e.e++,c[0]==C&&(c[0]=1));break}if(c[h]+=u,c[h]!=C)break;c[h--]=0,u=1}for(o=c.length;0===c[--o];)c.pop()}return F&&(e.e>m.maxE?(e.d=null,e.e=NaN):e.e<m.minE&&(e.e=0,e.d=[0])),e}function i(e,n,r){if(!e.isFinite())return f(e);var i,o=e.e,a=t(e.d),s=a.length;return n?(r&&(i=r-s)>0?a=a.charAt(0)+"."+a.slice(1)+u(i):s>1&&(a=a.charAt(0)+"."+a.slice(1)),a=a+(e.e<0?"e":"e+")+e.e):0>o?(a="0."+u(-o-1)+a,r&&(i=r-s)>0&&(a+=u(i))):o>=s?(a+=u(o+1-s),r&&(i=r-o-1)>0&&(a=a+"."+u(i))):((i=o+1)<s&&(a=a.slice(0,i)+"."+a.slice(i)),r&&(i=r-s)>0&&(o+1===s&&(a+="."),a+=u(i))),a}function o(e,t){var n=e[0];for(t*=L;n>=10;n/=10)t++;return t}function a(e){var t=e.length-1,n=t*L+1;if(t=e[t]){for(;t%10==0;t/=10)n--;for(t=e[0];t>=10;t/=10)n++}return n}function u(e){for(var t="";e--;)t+="0";return t}function s(e,t,n){for(var r,i=new e(t[0]),o=0;++o<t.length;){if(r=new e(t[o]),!r.s){i=r;break}i[n](r)&&(i=r)}return i}function f(e){return String(e.s*e.s/0)}function l(e,t){var n,r,i;for((n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(0>n&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):0>n&&(n=t.length),r=0;48===t.charCodeAt(r);r++);for(i=t.length;48===t.charCodeAt(i-1);--i);if(t=t.slice(r,i)){if(i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%L,0>n&&(r+=L),i>r){for(r&&e.d.push(+t.slice(0,r)),i-=L;i>r;)e.d.push(+t.slice(r,r+=L));t=t.slice(r),r=L-t.length}else r-=i;for(;r--;)t+="0";e.d.push(+t),F&&(e.e>e.constructor.maxE?(e.d=null,e.e=NaN):e.e<e.constructor.minE&&(e.e=0,e.d=[0]))}else e.e=0,e.d=[0];return e}function c(e,t){if("Infinity"===t||"NaN"===t)return+t||(e.s=NaN),e.e=NaN,e.d=null,e;throw Error(B+t)}function h(e){return new this(e).abs()}function m(e,t){return new this(e).plus(t)}function p(e){return r(e=new this(e),e.e+1,2)}function v(e){if(!e||"object"!=typeof e)throw Error(O+"Object expected");var t,n,r,i=["precision",1,_,"rounding",0,8,"toExpNeg",-T,0,"toExpPos",0,T,"maxE",0,T,"minE",-T,0,"modulo",0,9];for(t=0;t<i.length;t+=3)if(void 0!==(r=e[n=i[t]])){if(!(R(r)===r&&r>=i[t+1]&&r<=i[t+2]))throw Error(B+n+": "+r);this[n]=r}if(void 0!==(r=e[n="crypto"])){if(r!==!0&&r!==!1&&0!==r&&1!==r)throw Error(B+n+": "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(D);this[n]=!0}else this[n]=!1}return this}function g(e){function t(e){var n,r,i,o=this;if(!(o instanceof t))return new t(e);if(o.constructor=t,e instanceof t)return o.s=e.s,o.e=e.e,void(o.d=(e=e.d)?e.slice():e);if(i=typeof e,"number"===i){if(0===e)return o.s=0>1/e?-1:1,o.e=0,void(o.d=[0]);if(0>e?(e=-e,o.s=-1):o.s=1,e===~~e&&1e7>e){for(n=0,r=e;r>=10;r/=10)n++;return o.e=n,void(o.d=[e])}return 0*e!==0?(e||(o.s=NaN),o.e=NaN,void(o.d=null)):l(o,e.toString())}if("string"!==i)throw Error(B+e);return 45===e.charCodeAt(0)?(e=e.slice(1),o.s=-1):o.s=1,A.test(e)?l(o,e):c(o,e)}var n,r,i;if(t.prototype=H,t.ROUND_UP=0,t.ROUND_DOWN=1,t.ROUND_CEIL=2,t.ROUND_FLOOR=3,t.ROUND_HALF_UP=4,t.ROUND_HALF_DOWN=5,t.ROUND_HALF_EVEN=6,t.ROUND_HALF_CEIL=7,t.ROUND_HALF_FLOOR=8,t.EUCLID=9,t.config=t.set=v,t.clone=g,t.abs=h,t.add=m,t.ceil=p,t.div=d,t.floor=y,t.max=x,t.min=N,t.mod=k,t.mul=b,t.round=w,t.sign=E,t.sub=V,t.trunc=M,void 0===e&&(e={}),e)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],n=0;n<i.length;)e.hasOwnProperty(r=i[n++])||(e[r]=this[r]);return t.config(e),t}function d(e,t){return new this(e).div(t)}function y(e){return r(e=new this(e),e.e+1,3)}function x(){return s(this,arguments,"lt")}function N(){return s(this,arguments,"gt")}function k(e,t){return new this(e).mod(t)}function b(e,t){return new this(e).mul(t)}function w(e){return r(e=new this(e),e.e+1,this.rounding)}function E(e){return e=new this(e),e.d?e.d[0]?e.s:0*e.s:e.s||NaN}function V(e,t){return new this(e).sub(t)}function M(e){return r(e=new this(e),e.e+1,1)}var I,T=9e15,_=1e9,q="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",S={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-T,maxE:T,crypto:!1},F=!0,O="[DecimalError] ",B=O+"Invalid argument: ",D=O+"crypto unavailable",R=Math.floor,P=Math.pow,A=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,C=1e7,L=7,H=(q.length-1,{});H.absoluteValue=H.abs=function(){var e=new this.constructor(this);return e.s<0&&(e.s=1),r(e)},H.ceil=function(){return r(new this.constructor(this),this.e+1,2)},H.comparedTo=H.cmp=function(e){var t,n,r,i,o=this,a=o.d,u=(e=new o.constructor(e)).d,s=o.s,f=e.s;if(!a||!u)return s&&f?s!==f?s:a===u?0:!a^0>s?1:-1:NaN;if(!a[0]||!u[0])return a[0]?s:u[0]?-f:0;if(s!==f)return s;if(o.e!==e.e)return o.e>e.e^0>s?1:-1;for(r=a.length,i=u.length,t=0,n=i>r?r:i;n>t;++t)if(a[t]!==u[t])return a[t]>u[t]^0>s?1:-1;return r===i?0:r>i^0>s?1:-1},H.decimalPlaces=H.dp=function(){var e,t=this.d,n=NaN;if(t){if(e=t.length-1,n=(e-R(this.e/L))*L,e=t[e])for(;e%10==0;e/=10)n--;0>n&&(n=0)}return n},H.dividedBy=H.div=function(e){return U(this,new this.constructor(e))},H.dividedToIntegerBy=H.divToInt=function(e){var t=this,n=t.constructor;return r(U(t,new n(e),0,1,1),n.precision,n.rounding)},H.equals=H.eq=function(e){return 0===this.cmp(e)},H.floor=function(){return r(new this.constructor(this),this.e+1,3)},H.greaterThan=H.gt=function(e){return this.cmp(e)>0},H.greaterThanOrEqualTo=H.gte=function(e){var t=this.cmp(e);return 1==t||0===t},H.isFinite=function(){return!!this.d},H.isInteger=H.isInt=function(){return!!this.d&&R(this.e/L)>this.d.length-2},H.isNaN=function(){return!this.s},H.isNegative=H.isNeg=function(){return this.s<0},H.isPositive=H.isPos=function(){return this.s>0},H.isZero=function(){return!!this.d&&0===this.d[0]},H.lessThan=H.lt=function(e){return this.cmp(e)<0},H.lessThanOrEqualTo=H.lte=function(e){return this.cmp(e)<1},H.minus=H.sub=function(e){var t,n,i,a,u,s,f,l,c,h,m,p,v=this,g=v.constructor;if(e=new g(e),!v.d||!e.d)return v.s&&e.s?v.d?e.s=-e.s:e=new g(e.d||v.s!==e.s?v:NaN):e=new g(NaN),e;if(v.s!=e.s)return e.s=-e.s,v.plus(e);if(c=v.d,p=e.d,f=g.precision,l=g.rounding,!c[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!c[0])return new g(3===l?-0:0);e=new g(v)}return F?r(e,f,l):e}if(n=R(e.e/L),h=R(v.e/L),c=c.slice(),u=h-n){for(m=0>u,m?(t=c,u=-u,s=p.length):(t=p,n=h,s=c.length),i=Math.max(Math.ceil(f/L),s)+2,u>i&&(u=i,t.length=1),t.reverse(),i=u;i--;)t.push(0);t.reverse()}else{for(i=c.length,s=p.length,m=s>i,m&&(s=i),i=0;s>i;i++)if(c[i]!=p[i]){m=c[i]<p[i];break}u=0}for(m&&(t=c,c=p,p=t,e.s=-e.s),s=c.length,i=p.length-s;i>0;--i)c[s++]=0;for(i=p.length;i>u;){if(c[--i]<p[i]){for(a=i;a&&0===c[--a];)c[a]=C-1;--c[a],c[i]+=C}c[i]-=p[i]}for(;0===c[--s];)c.pop();for(;0===c[0];c.shift())--n;return c[0]?(e.d=c,e.e=o(c,n),F?r(e,f,l):e):new g(3===l?-0:0)},H.modulo=H.mod=function(e){var t,n=this,i=n.constructor;return e=new i(e),!n.d||!e.s||e.d&&!e.d[0]?new i(NaN):!e.d||n.d&&!n.d[0]?r(new i(n),i.precision,i.rounding):(F=!1,9==i.modulo?(t=U(n,e.abs(),0,3,1),t.s*=e.s):t=U(n,e,0,i.modulo,1),t=t.times(e),F=!0,n.minus(t))},H.negated=H.neg=function(){var e=new this.constructor(this);return e.s=-e.s,r(e)},H.plus=H.add=function(e){var t,n,i,a,u,s,f,l,c,h,m=this,p=m.constructor;if(e=new p(e),!m.d||!e.d)return m.s&&e.s?m.d||(e=new p(e.d||m.s===e.s?m:NaN)):e=new p(NaN),e;if(m.s!=e.s)return e.s=-e.s,m.minus(e);if(c=m.d,h=e.d,f=p.precision,l=p.rounding,!c[0]||!h[0])return h[0]||(e=new p(m)),F?r(e,f,l):e;if(u=R(m.e/L),i=R(e.e/L),c=c.slice(),a=u-i){for(0>a?(n=c,a=-a,s=h.length):(n=h,i=u,s=c.length),u=Math.ceil(f/L),s=u>s?u+1:s+1,a>s&&(a=s,n.length=1),n.reverse();a--;)n.push(0);n.reverse()}for(s=c.length,a=h.length,0>s-a&&(a=s,n=h,h=c,c=n),t=0;a;)t=(c[--a]=c[a]+h[a]+t)/C|0,c[a]%=C;for(t&&(c.unshift(t),++i),s=c.length;0==c[--s];)c.pop();return e.d=c,e.e=o(c,i),F?r(e,f,l):e},H.precision=H.sd=function(e){var t,n=this;if(void 0!==e&&e!==!!e&&1!==e&&0!==e)throw Error(B+e);return n.d?(t=a(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},H.round=function(){var e=this,t=e.constructor;return r(new t(e),e.e+1,t.rounding)},H.times=H.mul=function(e){var t,n,i,a,u,s,f,l,c,h=this,m=h.constructor,p=h.d,v=(e=new m(e)).d;if(e.s*=h.s,!(p&&p[0]&&v&&v[0]))return new m(!e.s||p&&!p[0]&&!v||v&&!v[0]&&!p?NaN:p&&v?0*e.s:e.s/0);for(n=R(h.e/L)+R(e.e/L),l=p.length,c=v.length,c>l&&(u=p,p=v,v=u,s=l,l=c,c=s),u=[],s=l+c,i=s;i--;)u.push(0);for(i=c;--i>=0;){for(t=0,a=l+i;a>i;)f=u[a]+v[i]*p[a-i-1]+t,u[a--]=f%C|0,t=f/C|0;u[a]=(u[a]+t)%C|0}for(;!u[--s];)u.pop();return t?++n:u.shift(),e.d=u,e.e=o(u,n),F?r(e,m.precision,m.rounding):e},H.toDecimalPlaces=H.toDP=function(e,t){var i=this,o=i.constructor;return i=new o(i),void 0===e?i:(n(e,0,_),void 0===t?t=o.rounding:n(t,0,8),r(i,e+i.e+1,t))},H.toExponential=function(e,t){var o,a=this,u=a.constructor;return void 0===e?o=i(a,!0):(n(e,0,_),void 0===t?t=u.rounding:n(t,0,8),a=r(new u(a),e+1,t),o=i(a,!0,e+1)),a.isNeg()&&!a.isZero()?"-"+o:o},H.toFixed=function(e,t){var o,a,u=this,s=u.constructor;return void 0===e?o=i(u):(n(e,0,_),void 0===t?t=s.rounding:n(t,0,8),a=r(new s(u),e+u.e+1,t),o=i(a,!1,e+a.e+1)),u.isNeg()&&!u.isZero()?"-"+o:o},H.toNearest=function(e,t){var i=this,o=i.constructor;if(i=new o(i),null==e){if(!i.d)return i;e=new o(1),t=o.rounding}else{if(e=new o(e),void 0!==t&&n(t,0,8),!i.d)return e.s?i:e;if(!e.d)return e.s&&(e.s=i.s),e}return e.d[0]?(F=!1,4>t&&(t=[4,5,7,8][t]),i=U(i,e,0,t,1).times(e),F=!0,r(i)):(e.s=i.s,i=e),i},H.toNumber=function(){return+this},H.toPrecision=function(e,t){var o,a=this,u=a.constructor;return void 0===e?o=i(a,a.e<=u.toExpNeg||a.e>=u.toExpPos):(n(e,1,_),void 0===t?t=u.rounding:n(t,0,8),a=r(new u(a),e,t),o=i(a,e<=a.e||a.e<=u.toExpNeg,e)),a.isNeg()&&!a.isZero()?"-"+o:o},H.toSignificantDigits=H.toSD=function(e,t){var i=this,o=i.constructor;return void 0===e?(e=o.precision,t=o.rounding):(n(e,1,_),void 0===t?t=o.rounding:n(t,0,8)),r(new o(i),e,t)},H.toString=function(){var e=this,t=e.constructor,n=i(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},H.truncated=H.trunc=function(){return r(new this.constructor(this),this.e+1,1)},H.valueOf=H.toJSON=function(){var e=this,t=e.constructor,n=i(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var U=function(){function e(e,t,n){var r,i=0,o=e.length;for(e=e.slice();o--;)r=e[o]*t+i,e[o]=r%n|0,i=r/n|0;return i&&e.unshift(i),e}function t(e,t,n,r){var i,o;if(n!=r)o=n>r?1:-1;else for(i=o=0;n>i;i++)if(e[i]!=t[i]){o=e[i]>t[i]?1:-1;break}return o}function n(e,t,n,r){for(var i=0;n--;)e[n]-=i,i=e[n]<t[n]?1:0,e[n]=i*r+e[n]-t[n];for(;!e[0]&&e.length>1;)e.shift()}return function(i,o,a,u,s,f){var l,c,h,m,p,v,g,d,y,x,N,k,b,w,E,V,M,T,_,q,S=i.constructor,F=i.s==o.s?1:-1,O=i.d,B=o.d;if(!(O&&O[0]&&B&&B[0]))return new S(i.s&&o.s&&(O?!B||O[0]!=B[0]:B)?O&&0==O[0]||!B?0*F:F/0:NaN);for(f?(p=1,c=i.e-o.e):(f=C,p=L,c=R(i.e/p)-R(o.e/p)),_=B.length,M=O.length,y=new S(F),x=y.d=[],h=0;B[h]==(O[h]||0);h++);if(B[h]>(O[h]||0)&&c--,null==a?(w=a=S.precision,u=S.rounding):w=s?a+(i.e-o.e)+1:a,0>w)x.push(1),v=!0;else{if(w=w/p+2|0,h=0,1==_){for(m=0,B=B[0],w++;(M>h||m)&&w--;h++)E=m*f+(O[h]||0),x[h]=E/B|0,m=E%B|0;v=m||M>h}else{for(m=f/(B[0]+1)|0,m>1&&(B=e(B,m,f),O=e(O,m,f),_=B.length,M=O.length),V=_,N=O.slice(0,_),k=N.length;_>k;)N[k++]=0;q=B.slice(),q.unshift(0),T=B[0],B[1]>=f/2&&++T;do m=0,l=t(B,N,_,k),0>l?(b=N[0],_!=k&&(b=b*f+(N[1]||0)),m=b/T|0,m>1?(m>=f&&(m=f-1),g=e(B,m,f),d=g.length,k=N.length,l=t(g,N,d,k),1==l&&(m--,n(g,d>_?q:B,d,f))):(0==m&&(l=m=1),g=B.slice()),d=g.length,k>d&&g.unshift(0),n(N,g,k,f),-1==l&&(k=N.length,l=t(B,N,_,k),1>l&&(m++,n(N,k>_?q:B,k,f))),k=N.length):0===l&&(m++,N=[0]),x[h++]=m,l&&N[0]?N[k++]=O[V]||0:(N=[O[V]],k=1);while((V++<M||void 0!==N[0])&&w--);v=void 0!==N[0]}x[0]||x.shift()}if(1==p)y.e=c,I=v;else{for(h=1,m=x[0];m>=10;m/=10)h++;y.e=h+c*p-1,r(y,s?a+y.e+1:a,u,v)}return y}}();S=g(S),S["default"]=S.ExpHelper=S,q=new S(q),S.LN10=q,e.ExpHelper=S}(this),function(e){var t=17,n=-324,r=BigInteger.parseInt("0"),i=BigInteger.parseInt("1"),o=BigInteger.parseInt("-1"),a=BigInteger.parseInt("-7"),u=BigInteger.parseInt("14"),s=BigInteger.parseInt("21"),f=BigInteger.parseInt("308"),l=BigInteger.parseInt("-324"),c=BigInteger.parseInt(padEnd("179769",309,"0")),h=c.negate(),m=BigInteger.parseInt("17"),p=[1e-323,1e-322,1e-321,1e-320,1e-319,1e-318,1e-317,1e-316,1e-315,1e-314,1e-313,1e-312,1e-311,1e-310,1e-309,1e-308,1e-307,1e-306,1e-305,1e-304,1e-303,1e-302,1e-301,1e-300,1e-299,1e-298,1e-297,1e-296,1e-295,1e-294,1e-293,1e-292,1e-291,1e-290,1e-289,1e-288,1e-287,1e-286,1e-285,1e-284,1e-283,1e-282,1e-281,1e-280,1e-279,1e-278,1e-277,1e-276,1e-275,1e-274,1e-273,1e-272,1e-271,1e-270,1e-269,1e-268,1e-267,1e-266,1e-265,1e-264,1e-263,1e-262,1e-261,1e-260,1e-259,1e-258,1e-257,1e-256,1e-255,1e-254,1e-253,1e-252,1e-251,1e-250,1e-249,1e-248,1e-247,1e-246,1e-245,1e-244,1e-243,1e-242,1e-241,1e-240,1e-239,1e-238,1e-237,1e-236,1e-235,1e-234,1e-233,1e-232,1e-231,1e-230,1e-229,1e-228,1e-227,1e-226,1e-225,1e-224,1e-223,1e-222,1e-221,1e-220,1e-219,1e-218,1e-217,1e-216,1e-215,1e-214,1e-213,1e-212,1e-211,1e-210,1e-209,1e-208,1e-207,1e-206,1e-205,1e-204,1e-203,1e-202,1e-201,1e-200,1e-199,1e-198,1e-197,1e-196,1e-195,1e-194,1e-193,1e-192,1e-191,1e-190,1e-189,1e-188,1e-187,1e-186,1e-185,1e-184,1e-183,1e-182,1e-181,1e-180,1e-179,1e-178,1e-177,1e-176,1e-175,1e-174,1e-173,1e-172,1e-171,1e-170,1e-169,1e-168,1e-167,1e-166,1e-165,1e-164,1e-163,1e-162,1e-161,1e-160,1e-159,1e-158,1e-157,1e-156,1e-155,1e-154,1e-153,1e-152,1e-151,1e-150,1e-149,1e-148,1e-147,1e-146,1e-145,1e-144,1e-143,1e-142,1e-141,1e-140,1e-139,1e-138,1e-137,1e-136,1e-135,1e-134,1e-133,1e-132,1e-131,1e-130,1e-129,1e-128,1e-127,1e-126,1e-125,1e-124,1e-123,1e-122,1e-121,1e-120,1e-119,1e-118,1e-117,1e-116,1e-115,1e-114,1e-113,1e-112,1e-111,1e-110,1e-109,1e-108,1e-107,1e-106,1e-105,1e-104,1e-103,1e-102,1e-101,1e-100,1e-99,1e-98,1e-97,1e-96,1e-95,1e-94,1e-93,1e-92,1e-91,1e-90,1e-89,1e-88,1e-87,1e-86,1e-85,1e-84,1e-83,1e-82,1e-81,1e-80,1e-79,1e-78,1e-77,1e-76,1e-75,1e-74,1e-73,1e-72,1e-71,1e-70,1e-69,1e-68,1e-67,1e-66,1e-65,1e-64,1e-63,1e-62,1e-61,1e-60,1e-59,1e-58,1e-57,1e-56,1e-55,1e-54,1e-53,1e-52,1e-51,1e-50,1e-49,1e-48,1e-47,1e-46,1e-45,1e-44,1e-43,1e-42,1e-41,1e-40,1e-39,1e-38,1e-37,1e-36,1e-35,1e-34,1e-33,1e-32,1e-31,1e-30,1e-29,1e-28,1e-27,1e-26,1e-25,1e-24,1e-23,1e-22,1e-21,1e-20,1e-19,1e-18,1e-17,1e-16,1e-15,1e-14,1e-13,1e-12,1e-11,1e-10,1e-9,1e-8,1e-7,1e-6,1e-5,1e-4,.001,.01,.1,1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20,1e21,1e22,1e23,1e24,1e25,1e26,1e27,1e28,1e29,1e30,1e31,1e32,1e33,1e34,1e35,1e36,1e37,1e38,1e39,1e40,1e41,1e42,1e43,1e44,1e45,1e46,1e47,1e48,1e49,1e50,1e51,1e52,1e53,1e54,1e55,1e56,1e57,1e58,1e59,1e60,1e61,1e62,1e63,1e64,1e65,1e66,1e67,1e68,1e69,1e70,1e71,1e72,1e73,1e74,1e75,1e76,1e77,1e78,1e79,1e80,1e81,1e82,1e83,1e84,1e85,1e86,1e87,1e88,1e89,1e90,1e91,1e92,1e93,1e94,1e95,1e96,1e97,1e98,1e99,1e100,1e101,1e102,1e103,1e104,1e105,1e106,1e107,1e108,1e109,1e110,1e111,1e112,1e113,1e114,1e115,1e116,1e117,1e118,1e119,1e120,1e121,1e122,1e123,1e124,1e125,1e126,1e127,1e128,1e129,1e130,1e131,1e132,1e133,1e134,1e135,1e136,1e137,1e138,1e139,1e140,1e141,1e142,1e143,1e144,1e145,1e146,1e147,1e148,1e149,1e150,1e151,1e152,1e153,1e154,1e155,1e156,1e157,1e158,1e159,1e160,1e161,1e162,1e163,1e164,1e165,1e166,1e167,1e168,1e169,1e170,1e171,1e172,1e173,1e174,1e175,1e176,1e177,1e178,1e179,1e180,1e181,1e182,1e183,1e184,1e185,1e186,1e187,1e188,1e189,1e190,1e191,1e192,1e193,1e194,1e195,1e196,1e197,1e198,1e199,1e200,1e201,1e202,1e203,1e204,1e205,1e206,1e207,1e208,1e209,1e210,1e211,1e212,1e213,1e214,1e215,1e216,1e217,1e218,1e219,1e220,1e221,1e222,1e223,1e224,1e225,1e226,1e227,1e228,1e229,1e230,1e231,1e232,1e233,1e234,1e235,1e236,1e237,1e238,1e239,1e240,1e241,1e242,1e243,1e244,1e245,1e246,1e247,1e248,1e249,1e250,1e251,1e252,1e253,1e254,1e255,1e256,1e257,1e258,1e259,1e260,1e261,1e262,1e263,1e264,1e265,1e266,1e267,1e268,1e269,1e270,1e271,1e272,1e273,1e274,1e275,1e276,1e277,1e278,1e279,1e280,1e281,1e282,1e283,1e284,1e285,1e286,1e287,1e288,1e289,1e290,1e291,1e292,1e293,1e294,1e295,1e296,1e297,1e298,1e299,1e300,1e301,1e302,1e303,1e304,1e305,1e306,1e307,1e308],v=323,g=function(){function e(t){_classCallCheck(this,e),t instanceof e?this.fromDecimal(t):"number"==typeof t?this.fromNumber(t):"string"==typeof t?this.fromString(t):(this.mantissa=0,this.exponent=0)}return _createClass(e,[{key:"normalize",value:function(){if(0==this.mantissa)return this.mantissa=0,void(this.exponent=r);if(!(this.mantissa>=1&&this.mantissa<10||Number.isNaN(this.mantissa)||Number.isNaN(this.exponent))){var t=Math.floor(Math.log10(Math.abs(this.mantissa)));return this.mantissa=this.mantissa/p[t+v],this.exponent=this.exponent.add(e.toBigInteger(t)),this}}},{key:"fromMantissaExponent",value:function(t,n){return Number.isFinite(t)||(t=Number.NaN,n=c),this.mantissa=t,this.exponent=e.toBigInteger(n),this.normalize(),this}},{key:"fromMantissaExponent_noNormalize",value:function(t,n){return this.mantissa=t,this.exponent=e.toBigInteger(n),this}},{key:"fromDecimal",value:function(e){return this.mantissa=e.mantissa,this.exponent=e.exponent,this}},{key:"fromNumber",value:function(t){if(Number.isNaN(t))this.mantissa=Number.NaN,this.exponent=c;else if(t==Number.POSITIVE_INFINITY)this.mantissa=1,this.exponent=c;else if(t==Number.NEGATIVE_INFINITY)this.mantissa=-1,this.exponent=c;else if(0==t)this.mantissa=0,this.exponent=r;else{var i=Math.floor(Math.log10(Math.abs(t)));this.exponent=e.toBigInteger(i),i==n?this.mantissa=10*t/1e-323:this.mantissa=t/p[i+v],this.normalize()}return this}},{key:"fromString",value:function(t){if(-1!=t.indexOf("e")){t=t.replace("(","").replace(")","");var n=t.indexOf("e"),r=[t.substring(0,n),t.substring(n+1)];this.mantissa=parseFloat(r[0]),this.exponent=e.toBigInteger(parseFloat(r[1])),this.normalize()}else if("NaN"==t)this.mantissa=Number.NaN,this.exponent=c;else if(this.fromNumber(parseFloat(t)),Number.isNaN(this.mantissa))throw Error("[DecimalError] Invalid argument: "+t);return this}},{key:"fromValue",value:function(t){return t instanceof e?this.fromDecimal(t):"number"==typeof t?this.fromNumber(t):"string"==typeof t?this.fromString(t):(this.mantissa=0,this.exponent=0,this)}}],[{key:"toBigInteger",value:function(t){return t instanceof e?BigInteger.parseInt(t.round().toFixed()):"number"==typeof t?BigInteger.parseInt(new e(t).round().toFixed()):"string"==typeof t?BigInteger.parseInt(t):t instanceof BigIntegerInternal?t:r}}]),_createClass(e,[{key:"toNumber",value:function(){if(!Number.isFinite(this.mantissa))return Number.NaN;if(this.exponent.compareTo(f)>0)return this.mantissa>0?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;if(this.exponent.compareTo(l)<0)return 0;if(0==this.exponent.compareTo(l))return this.mantissa>0?5e-324:-5e-324;var e=this.mantissa*p[parseInt(this.exponent.toString())+v];if(!Number.isFinite(e)||this.exponent.compareTo(r)<0)return e;var t=Math.round(e);return Math.abs(t-e)<1e-10?t:e}},{key:"mantissaWithDecimalPlaces",value:function(e){if(Number.isNaN(this.mantissa))return Number.NaN;if(0==this.mantissa)return 0;var t=e+1,n=Math.ceil(Math.log10(Math.abs(this.mantissa))),r=Math.round(this.mantissa*Math.pow(10,t-n))*Math.pow(10,n-t);return parseFloat(r.toFixed(Math.max(t-n,0)))}},{key:"toString",value:function(){return Number.isNaN(this.mantissa)?"NaN":this.exponent.compareTo(c)>=0?this.mantissa>0?"Infinity":"-Infinity":this.exponent.compareTo(h)<=0||0==this.mantissa?"0":this.exponent.compareTo(s)<0&&this.exponent.compareTo(a)>0?this.toNumber().toString():this.mantissa+"e"+(this.exponent.compareTo(r)>=0?"+":"")+this.exponent.toString()}},{key:"toExponential",value:function(e){if(Number.isNaN(this.mantissa))return"NaN";if(this.exponent.compareTo(c)>=0)return this.mantissa>0?"Infinity":"-Infinity";if(this.exponent.compareTo(h)<=0||0==this.mantissa)return"0"+(e>0?padEnd(".",e+1,"0"):"")+"e+0";if(this.exponent.compareTo(l)>0&&this.exponent.compareTo(f)<0)return this.toNumber().toExponential(e);Number.isFinite(e)||(e=t);var n=e+1,i=Math.max(1,Math.ceil(Math.log10(Math.abs(this.mantissa)))),o=Math.round(this.mantissa*Math.pow(10,n-i))*Math.pow(10,i-n);return o.toFixed(Math.max(n-i,0))+"e"+(this.exponent.compareTo(r)>=0?"+":"")+this.exponent.toString()}},{key:"toFixed",value:function(e){return Number.isNaN(this.mantissa)?"NaN":this.exponent.compareTo(c)>=0?this.mantissa>0?"Infinity":"-Infinity":this.exponent.compareTo(h)<=0||0==this.mantissa?"0"+(e>0?padEnd(".",e+1,"0"):""):this.exponent.compareTo(m)>=0?padEnd(this.mantissa.toString().replace(".",""),this.exponent.add(i).toString(),"0")+(e>0?padEnd(".",e+1,"0"):""):this.toNumber().toFixed(e)}},{key:"toPrecision",value:function(e){return parseFloat(this.exponent.toString())<=-7?this.toExponential(e-1):e>parseFloat(this.exponent.toString())?this.toFixed(e-parseFloat(this.exponent.toString())-1):this.toExponential(e-1)}},{key:"valueOf",value:function(){return this.toString()}},{key:"toJSON",value:function(){return this.toString()}},{key:"toStringWithDecimalPlaces",value:function(e){return this.toExponential(e)}},{key:"abs",value:function(){return e.fromMantissaExponent(Math.abs(this.mantissa),this.exponent)}},{key:"neg",value:function(){return e.fromMantissaExponent(-this.mantissa,this.exponent)}},{key:"negate",value:function(){return this.neg()}},{key:"negated",value:function(){return this.neg()}},{key:"sign",value:function(){return Math.sign(this.mantissa)}},{key:"sgn",value:function(){return this.sign()}},{key:"round",value:function(){return this.exponent.compareTo(o)<0?new e(0):this.exponent.compareTo(m)<0?new e(Math.round(this.toNumber())):this}},{key:"floor",value:function(){return this.exponent.compareTo(o)<0?new e(Math.sign(this.mantissa)>=0?0:-1):this.exponent.compareTo(m)<0?new e(Math.floor(this.toNumber())):this;
}},{key:"ceil",value:function(){return this.exponent.compareTo(o)<0?new e(Math.sign(this.mantissa)>0?1:0):this.exponent.compareTo(m)<0?new e(Math.ceil(this.toNumber())):this}},{key:"trunc",value:function(){return this.exponent.compareTo(r)<0?new e(0):this.exponent.compareTo(m)<0?new e(Math.trunc(this.toNumber())):this}},{key:"add",value:function(t){if(t=e.fromValue(t),0==this.mantissa)return t;if(0==t.mantissa)return this;var n,r;return this.exponent.compareTo(t.exponent)>=0?(n=this,r=t):(n=t,r=this),n.exponent.subtract(r.exponent).compareTo(m)>0?n:e.fromMantissaExponent(Math.round(1e14*n.mantissa+1e14*r.mantissa*p[parseInt(r.exponent.subtract(n.exponent).toString())+v]),n.exponent.subtract(u))}},{key:"plus",value:function(e){return this.add(e)}},{key:"sub",value:function(t){return t=e.fromValue(t),this.add(e.fromMantissaExponent(-t.mantissa,t.exponent))}},{key:"subtract",value:function(e){return this.sub(e)}},{key:"minus",value:function(e){return this.sub(e)}},{key:"mul",value:function(t){return t=e.fromValue(t),e.fromMantissaExponent(this.mantissa*t.mantissa,this.exponent.add(t.exponent))}},{key:"multiply",value:function(e){return this.mul(e)}},{key:"times",value:function(e){return this.mul(e)}},{key:"div",value:function(t){return t=e.fromValue(t),this.mul(t.recip())}},{key:"divide",value:function(e){return this.div(e)}},{key:"divideBy",value:function(e){return this.div(e)}},{key:"dividedBy",value:function(e){return this.div(e)}},{key:"recip",value:function(){return e.fromMantissaExponent(1/this.mantissa,this.exponent.negate())}},{key:"reciprocal",value:function(){return this.recip()}},{key:"reciprocate",value:function(){return this.recip()}},{key:"cmp",value:function(t){if(t=e.fromValue(t),0==this.mantissa){if(0==t.mantissa)return 0;if(t.mantissa<0)return 1;if(t.mantissa>0)return-1}else if(0==t.mantissa){if(this.mantissa<0)return-1;if(this.mantissa>0)return 1}return this.mantissa>0?t.mantissa<0?1:this.exponent.compareTo(t.exponent)>0?1:this.exponent.compareTo(t.exponent)<0?-1:this.mantissa>t.mantissa?1:this.mantissa<t.mantissa?-1:0:this.mantissa<0?t.mantissa>0?-1:this.exponent.compareTo(t.exponent)>0?-1:this.exponent.compareTo(t.exponent)<0?1:this.mantissa>t.mantissa?1:this.mantissa<t.mantissa?-1:0:void 0}},{key:"compare",value:function(e){return this.cmp(e)}},{key:"eq",value:function(t){return t=e.fromValue(t),this.mantissa==t.mantissa&&0==this.exponent.compareTo(t.exponent)}},{key:"equals",value:function(e){return this.eq(e)}},{key:"neq",value:function(t){return t=e.fromValue(t),this.mantissa!=t.mantissa||0!=this.exponent.compareTo(t.exponent)}},{key:"notEquals",value:function(e){return this.neq(e)}},{key:"lt",value:function(t){return t=e.fromValue(t),0==this.mantissa?t.mantissa>0:0==t.mantissa?this.mantissa<=0:0==this.exponent.compareTo(t.exponent)?this.mantissa<t.mantissa:this.mantissa>0?t.mantissa>0&&this.exponent.compareTo(t.exponent)<0:t.mantissa>0||this.exponent.compareTo(t.exponent)>0}},{key:"lte",value:function(t){return t=e.fromValue(t),0==this.mantissa?t.mantissa>=0:0==t.mantissa?this.mantissa<=0:0==this.exponent.compareTo(t.exponent)?this.mantissa<=t.mantissa:this.mantissa>0?t.mantissa>0&&this.exponent.compareTo(t.exponent)<0:t.mantissa>0||this.exponent.compareTo(t.exponent)>0}},{key:"gt",value:function(t){return t=e.fromValue(t),0==this.mantissa?t.mantissa<0:0==t.mantissa?this.mantissa>0:0==this.exponent.compareTo(t.exponent)?this.mantissa>t.mantissa:this.mantissa>0?t.mantissa<0||this.exponent.compareTo(t.exponent)>0:t.mantissa<0&&this.exponent.compareTo(t.exponent)<0}},{key:"gte",value:function(t){return t=e.fromValue(t),0==this.mantissa?t.mantissa<=0:0==t.mantissa?this.mantissa>0:0==this.exponent.compareTo(t.exponent)?this.mantissa>=t.mantissa:this.mantissa>0?t.mantissa<0||this.exponent.compareTo(t.exponent)>0:t.mantissa<0&&this.exponent.compareTo(t.exponent)<0}},{key:"max",value:function(t){return t=e.fromValue(t),this.gte(t)?this:t}},{key:"min",value:function(t){return t=e.fromValue(t),this.lte(t)?this:t}},{key:"cmp_tolerance",value:function(t,n){return t=e.fromValue(t),this.eq_tolerance(t,n)?0:this.cmp(t)}},{key:"compare_tolerance",value:function(e,t){return this.cmp_tolerance(e,t)}},{key:"eq_tolerance",value:function(t,n){return t=e.fromValue(t),e.lte(this.sub(t).abs(),e.max(this.abs(),t.abs()).mul(n))}},{key:"equals_tolerance",value:function(e,t){return this.eq_tolerance(e,t)}},{key:"neq_tolerance",value:function(t,n){return t=e.fromValue(t),!this.eq_tolerance(t,n)}},{key:"notEquals_tolerance",value:function(e,t){return this.neq_tolerance(e,t)}},{key:"lt_tolerance",value:function(t,n){return t=e.fromValue(t),this.eq_tolerance(t,n)?!1:this.lt(t)}},{key:"lte_tolerance",value:function(t,n){return t=e.fromValue(t),this.eq_tolerance(t,n)?!0:this.lt(t)}},{key:"gt_tolerance",value:function(t,n){return t=e.fromValue(t),this.eq_tolerance(t,n)?!1:this.gt(t)}},{key:"gte_tolerance",value:function(t,n){return t=e.fromValue(t),this.eq_tolerance(t,n)?!0:this.gt(t)}},{key:"log10",value:function(){return parseInt(this.exponent.toString())+Math.log10(this.mantissa)}},{key:"log",value:function(e){return Math.LN10/Math.log(e)*this.log10()}},{key:"log2",value:function(){return 3.321928094887362*this.log10()}},{key:"ln",value:function(){return 2.302585092994046*this.log10()}},{key:"logarithm",value:function(e){return this.log(e)}},{key:"pow",value:function(n){var r=null;if(n instanceof e&&(n=n.toNumber()),n instanceof BigIntegerInternal&&(r=n,n=parseInt(n.toString())),"string"==typeof n&&(-1==n.indexOf(".")&&-1==n.indexOf("e")&&(r=BigInteger.parseInt(n)),n=parseFloat(n)),Number.isInteger(n)){var i=Math.pow(this.mantissa,n);if(Number.isFinite(i))return null!=r?e.fromMantissaExponent(i,this.exponent.multiply(r)):e.fromMantissaExponent(i,this.exponent.multiply(e.toBigInteger(n)))}ExpHelper.precision=t+this.exponent.toString().length;var o=new ExpHelper(n).mul(new ExpHelper(this.exponent.toString())),a=o.trunc(),u=o.sub(a).toNumber(),i=Math.pow(10,n*Math.log10(this.mantissa)+u);return Number.isFinite(i)?e.fromMantissaExponent(i,a.toFixed()):e.pow10(n*this.log10())}},{key:"pow_base",value:function(t){return t=e.fromValue(t),t.pow(this)}},{key:"factorial",value:function(){var t=this.toNumber()+1;return e.pow(t/Math.E*Math.sqrt(t*Math.sinh(1/t)+1/(810*Math.pow(t,6))),t).mul(Math.sqrt(2*Math.PI/t))}},{key:"exp",value:function g(){var n=this.toNumber();if(!Number.isFinite(n))return n;if(n>-706&&709>n)return e.fromNumber(Math.exp(n));var r,g,i;return ExpHelper.precision=t+parseInt(this.exponent.toString()),r=new ExpHelper(this.toNumber()),g=0,i=parseInt(this.exponent.toString()),i>=0&&(g=r.div(ExpHelper.LN10).trunc(),n=g.mul(ExpHelper.LN10),r=r.sub(n).toNumber(),r>=Math.LN10&&(g=g.add(1),r-=Math.LN10)),0>r&&(g=g.sub(1),r+=Math.LN10),r=Math.exp(r),g.eq(0)||(i=e.toBigInteger(g.floor().toFixed()),r=e.fromMantissaExponent(r,i)),r}},{key:"sqr",value:function(){return this.pow(2)}},{key:"sqrt",value:function(){return this.pow(.5)}},{key:"cube",value:function(){return this.pow(3)}},{key:"cbrt",value:function(){return this.pow(1/3)}},{key:"sinh",value:function(){return this.exp().sub(this.negate().exp()).div(2)}},{key:"cosh",value:function(){return this.exp().add(this.negate().exp()).div(2)}},{key:"tanh",value:function(){return this.sinh().div(this.cosh())}},{key:"asinh",value:function(){return e.ln(this.add(this.sqr().add(1).sqrt()))}},{key:"acosh",value:function(){return e.ln(this.add(this.sqr().sub(1).sqrt()))}},{key:"atanh",value:function(){return this.abs().gte(1)?Number.NaN:e.ln(this.add(1).div(new e(1).sub(this))).div(2)}},{key:"ascensionPenalty",value:function(e){return 0==e?this:this.pow(Math.pow(10,-e))}},{key:"egg",value:function(){return this.add(9)}},{key:"lessThanOrEqualTo",value:function(e){return this.cmp(e)<1}},{key:"lessThan",value:function(e){return this.cmp(e)<0}},{key:"greaterThanOrEqualTo",value:function(e){return this.cmp(e)>-1}},{key:"greaterThan",value:function(e){return this.cmp(e)>0}},{key:"m",get:function(){return this.mantissa},set:function(e){this.mantissa=e}},{key:"e",get:function(){return this.exponent},set:function(e){this.exponent=e}}],[{key:"fromMantissaExponent",value:function(t,n){return(new e).fromMantissaExponent(t,n)}},{key:"fromMantissaExponent_noNormalize",value:function(t,n){return(new e).fromMantissaExponent_noNormalize(t,n)}},{key:"fromDecimal",value:function(t){return(new e).fromDecimal(t)}},{key:"fromNumber",value:function(t){return(new e).fromNumber(t)}},{key:"fromString",value:function(t){return(new e).fromString(t)}},{key:"fromValue",value:function(t){return t instanceof e?t:new e(t)}},{key:"abs",value:function(t){return t=e.fromValue(t),t.abs()}},{key:"neg",value:function(t){return t=e.fromValue(t),t.neg()}},{key:"negate",value:function(t){return t=e.fromValue(t),t.neg()}},{key:"negated",value:function(t){return t=e.fromValue(t),t.neg()}},{key:"sign",value:function(t){return t=e.fromValue(t),t.sign()}},{key:"sgn",value:function(t){return t=e.fromValue(t),t.sign()}},{key:"round",value:function(t){return t=e.fromValue(t),t.round()}},{key:"floor",value:function(t){return t=e.fromValue(t),t.floor()}},{key:"ceil",value:function(t){return t=e.fromValue(t),t.ceil()}},{key:"trunc",value:function(t){return t=e.fromValue(t),t.trunc()}},{key:"add",value:function(t,n){return t=e.fromValue(t),t.add(n)}},{key:"plus",value:function(t,n){return t=e.fromValue(t),t.add(n)}},{key:"sub",value:function(t,n){return t=e.fromValue(t),t.sub(n)}},{key:"subtract",value:function(t,n){return t=e.fromValue(t),t.sub(n)}},{key:"minus",value:function(t,n){return t=e.fromValue(t),t.sub(n)}},{key:"mul",value:function(t,n){return t=e.fromValue(t),t.mul(n)}},{key:"multiply",value:function(t,n){return t=e.fromValue(t),t.mul(n)}},{key:"times",value:function(t,n){return t=e.fromValue(t),t.mul(n)}},{key:"div",value:function(t,n){return t=e.fromValue(t),t.div(n)}},{key:"divide",value:function(t,n){return t=e.fromValue(t),t.div(n)}},{key:"recip",value:function(t){return t=e.fromValue(t),t.recip()}},{key:"reciprocal",value:function(t){return t=e.fromValue(t),t.recip()}},{key:"reciprocate",value:function(t){return t=e.fromValue(t),t.reciprocate()}},{key:"cmp",value:function(t,n){return t=e.fromValue(t),t.cmp(n)}},{key:"compare",value:function(t,n){return t=e.fromValue(t),t.cmp(n)}},{key:"eq",value:function(t,n){return t=e.fromValue(t),t.eq(n)}},{key:"equals",value:function(t,n){return t=e.fromValue(t),t.eq(n)}},{key:"neq",value:function(t,n){return t=e.fromValue(t),t.neq(n)}},{key:"notEquals",value:function(t,n){return t=e.fromValue(t),t.notEquals(n)}},{key:"lt",value:function(t,n){return t=e.fromValue(t),t.lt(n)}},{key:"lte",value:function(t,n){return t=e.fromValue(t),t.lte(n)}},{key:"gt",value:function(t,n){return t=e.fromValue(t),t.gt(n)}},{key:"gte",value:function(t,n){return t=e.fromValue(t),t.gte(n)}},{key:"max",value:function(t,n){return t=e.fromValue(t),t.max(n)}},{key:"min",value:function(t,n){return t=e.fromValue(t),t.min(n)}},{key:"cmp_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.cmp_tolerance(n,r)}},{key:"compare_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.cmp_tolerance(n,r)}},{key:"eq_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.eq_tolerance(n,r)}},{key:"equals_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.eq_tolerance(n,r)}},{key:"neq_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.neq_tolerance(n,r)}},{key:"notEquals_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.notEquals_tolerance(n,r)}},{key:"lt_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.lt_tolerance(n,r)}},{key:"lte_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.lte_tolerance(n,r)}},{key:"gt_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.gt_tolerance(n,r)}},{key:"gte_tolerance",value:function(t,n,r){return t=e.fromValue(t),t.gte_tolerance(n,r)}},{key:"log10",value:function(t){return t=e.fromValue(t),t.log10()}},{key:"log",value:function(t,n){return t=e.fromValue(t),t.log(n)}},{key:"log2",value:function(t){return t=e.fromValue(t),t.log2()}},{key:"ln",value:function(t){return t=e.fromValue(t),t.ln()}},{key:"logarithm",value:function(t,n){return t=e.fromValue(t),t.logarithm(n)}},{key:"pow10",value:function(t){return Number.isInteger(t)?e.fromMantissaExponent_noNormalize(1,t):e.fromMantissaExponent(Math.pow(10,t%1),Math.trunc(t))}},{key:"pow",value:function(t,n){return 10==t&&Number.isInteger(n)?e.fromMantissaExponent(1,n):(t=e.fromValue(t),t.pow(n))}},{key:"exp",value:function(t){return t=e.fromValue(t),t.exp()}},{key:"sqr",value:function(t){return t=e.fromValue(t),t.sqr()}},{key:"sqrt",value:function(t){return t=e.fromValue(t),t.sqrt()}},{key:"cube",value:function(t){return t=e.fromValue(t),t.cube()}},{key:"cbrt",value:function(t){return t=e.fromValue(t),t.cbrt()}},{key:"affordGeometricSeries",value:function(t,n,r,i){t=e.fromValue(t),n=e.fromValue(n),r=e.fromValue(r);var o=n.mul(e.pow(r,i));return e.floor(e.log10(t.div(o).mul(r.sub(1)).add(1))/e.log10(r))}},{key:"sumGeometricSeries",value:function(t,n,r,i){n=e.fromValue(n),r=e.fromValue(r);var o=n.mul(e.pow(r,i));return o.mul(e.sub(1,e.pow(r,t))).div(e.sub(1,r))}},{key:"affordArithmeticSeries",value:function(t,n,r,i){t=e.fromValue(t),n=e.fromValue(n),r=e.fromValue(r),i=e.fromValue(i);var o=n.add(e.mul(i,r)),a=o.sub(r.div(2)),u=a.pow(2);return e.floor(a.neg().add(e.sqrt(u.add(e.mul(r,t).mul(2)))).div(r))}},{key:"sumArithmeticSeries",value:function(t,n,r,i){t=e.fromValue(t),n=e.fromValue(n),r=e.fromValue(r),i=e.fromValue(i);var o=n.add(e.mul(i,r));return e.div(t,2).mul(e.mul(2,o).plus(t.sub(1).mul(r)))}},{key:"efficiencyOfPurchase",value:function(t,n,r){return t=e.fromValue(t),n=e.fromValue(n),r=e.fromValue(r),e.add(t.div(n),t.div(r))}},{key:"randomDecimalForTesting",value:function(t){if(20*Math.random()<1)return e.fromMantissaExponent(0,0);var n=10*Math.random();10*Math.random()<1&&(n=Math.round(n)),n*=Math.sign(2*Math.random()-1);var r=Math.floor(Math.random()*t*2)-t;return e.fromMantissaExponent(n,r)}}]),e}();if("function"==typeof define&&define.amd)define(function(){return g});else if("undefined"!=typeof module&&module.exports)module.exports=g;else{e||(e="undefined"!=typeof self&&self&&self.self==self?self:Function("return this")());var d=e.Decimal;g.noConflict=function(){return e.Decimal=d,g},e.Decimal=g}}(void 0);