From 1e7ab9214336d8899c97e0b86fa9894eef27cb5b Mon Sep 17 00:00:00 2001 From: Richard Ainger Date: Mon, 29 Jan 2018 07:44:16 +1000 Subject: [PATCH] Applied iOS 10.3 workaround to min.js and es6.js variations of Decimal.js. --- decimal.es6.js | 22 +++++++++++++--------- decimal.min.js | 8 +++++--- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/decimal.es6.js b/decimal.es6.js index a2fdcc6..9aad05b 100644 --- a/decimal.es6.js +++ b/decimal.es6.js @@ -1376,7 +1376,7 @@ P.minus = P.sub = function (y) { for (; xd[--len] === 0;) xd.pop(); // Remove leading zeros and adjust exponent accordingly. - for (; xd[0] === 0; xd.shift()) --e; + for (; xd[0] === 0; xd.splice(0, 1)) --e; // Zero? if (!xd[0]) return new Ctor(rm === 3 ? -0 : 0); @@ -1600,7 +1600,7 @@ P.plus = P.add = function (y) { } if (carry) { - xd.unshift(carry); + xd = [carry].concat(xd); ++e; } @@ -1905,7 +1905,7 @@ P.times = P.mul = function (y) { for (; !r[--rL];) r.pop(); if (carry) ++e; - else r.shift(); + else r.splice(0, 1); y.d = r; y.e = getBase10Exponent(r, e); @@ -2666,7 +2666,9 @@ var divide = (function () { carry = temp / base | 0; } - if (carry) x.unshift(carry); + if (carry) { + x = [carry].concat(x); + } return x; } @@ -2699,7 +2701,7 @@ var divide = (function () { } // Remove leading zeros. - for (; !a[0] && a.length > 1;) a.shift(); + for (; !a[0] && a.length > 1;) a.splice(0, 1); } return function (x, y, pr, rm, dp, base) { @@ -2794,7 +2796,7 @@ var divide = (function () { for (; remL < yL;) rem[remL++] = 0; yz = yd.slice(); - yz.unshift(0); + yz = [0].concat(yz); yd0 = yd[0]; if (yd[1] >= base / 2) ++yd0; @@ -2851,7 +2853,9 @@ var divide = (function () { } prodL = prod.length; - if (prodL < remL) prod.unshift(0); + if (prodL < remL) { + prod = [0].concat(prod); + } // Subtract product from remainder. subtract(rem, prod, remL, base); @@ -2895,7 +2899,7 @@ var divide = (function () { } // Leading zero? - if (!qd[0]) qd.shift(); + if (!qd[0]) qd.splice(0, 1); } // logBase is 1 when divide is being used for base conversion. @@ -3845,7 +3849,7 @@ function toStringBinary(x, baseOut, sd, rm) { xd[sd] = 0; if (!sd) { ++e; - xd.unshift(1); + xd = [1].concat(xd); } } } diff --git a/decimal.min.js b/decimal.min.js index f41ea91..cbc9df0 100644 --- a/decimal.min.js +++ b/decimal.min.js @@ -1,3 +1,5 @@ -/* decimal.js v7.2.1 https://github.com/MikeMcl/decimal.js/LICENCE */ -!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=Rn-t.length,i&&(s+=d(i)),s+=t;o=n[e],t=o+"",i=Rn-t.length,i&&(s+=d(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(En+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+=Rn,r=0):(r=Math.ceil((e+1)/Rn),e%=Rn),s=On(10,Rn-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)==On(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)==On(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]+=wn.indexOf(n.charAt(o++)),t=0;ti-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(1));for(var s=i;s--;){var o=e.times(e);e=o.times(o).minus(o).times(8).plus(1)}return n.precision-=i,e}function o(n,e,i,t){var r,s,o,u,c,f,a,h,d,l=n.constructor;n:if(null!=e){if(h=n.d,!h)return n;for(r=1,u=h[0];u>=10;u/=10)r++;if(s=e-r,0>s)s+=Rn,o=e,a=h[d=0],c=a/On(10,r-o-1)%10|0;else if(d=Math.ceil((s+1)/Rn),u=h.length,d>=u){if(!t)break n;for(;u++<=d;)h.push(0);a=c=0,r=1,s%=Rn,o=s-Rn+1}else{for(a=u=h[d],r=1;u>=10;u/=10)r++;s%=Rn,o=s-Rn+r,c=0>o?0:a/On(10,r-o-1)%10|0}if(t=t||0>e||void 0!==h[d+1]||(0>o?a:a%On(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?a/On(10,r-o):0:h[d-1])%10&1||i==(n.s<0?8:7)),1>e||!h[0])return h.length=0,f?(e-=n.e+1,h[0]=On(10,(Rn-e%Rn)%Rn),n.e=-e||0):h[0]=n.e=0,n;if(0==s?(h.length=d,u=1,d--):(h.length=d+1,u=On(10,Rn-s),h[d]=o>0?(a/On(10,r-o)%On(10,o)|0)*u:0),f)for(;;){if(0==d){for(s=1,o=h[0];o>=10;o/=10)s++;for(o=h[0]+=u,u=1;o>=10;o/=10)u++;s!=u&&(n.e++,h[0]==Pn&&(h[0]=1));break}if(h[d]+=u,h[d]!=Pn)break;h[d--]=0,u=1}for(s=h.length;0===h[--s];)h.pop()}return bn&&(n.e>l.maxE?(n.d=null,n.e=NaN):n.e0?o=o.charAt(0)+"."+o.slice(1)+d(r):u>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(n.e<0?"e":"e+")+n.e):0>s?(o="0."+d(-s-1)+o,t&&(r=t-u)>0&&(o+=d(r))):s>=u?(o+=d(s+1-u),t&&(r=t-s-1)>0&&(o=o+"."+d(r))):((r=s+1)0&&(s+1===u&&(o+="."),o+=d(r))),o}function c(n,e){var i=n[0];for(e*=Rn;i>=10;i/=10)e++;return e}function f(n,e,i){if(e>Un)throw bn=!0,i&&(n.precision=i),Error(Mn);return o(new n(mn),e,1,!0)}function a(n,e,i){if(e>_n)throw Error(Mn);return o(new n(vn),e,i,!0)}function h(n){var e=n.length-1,i=e*Rn+1;if(e=n[e]){for(;e%10==0;e/=10)i--;for(e=n[0];e>=10;e/=10)i++}return i}function d(n){for(var e="";n--;)e+="0";return e}function l(n,e,i,t){var r,s=new n(1),o=Math.ceil(t/Rn+4);for(bn=!1;;){if(i%2&&(s=s.times(e),q(s.d,o)&&(r=!0)),i=qn(i/2),0===i){i=s.d.length-1,r&&0===s.d[i]&&++s.d[i];break}e=e.times(e),q(e.d,o)}return bn=!0,s}function p(n){return 1&n.d[n.d.length-1]}function g(n,e,i){for(var t,r=new n(e[0]),s=0;++s17)return new g(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(null==i?(bn=!1,h=m):h=i,a=new g(.03125);n.e>-2;)n=n.times(a),p+=5;for(s=Math.log(On(2,p))/Math.LN10*2+5|0,h+=s,r=c=f=new g(1),g.precision=h;;){if(c=o(c.times(n),h,1),r=r.times(++l),a=f.plus(Sn(c,r,h,1)),e(a.d).slice(0,h)===e(f.d).slice(0,h)){for(u=p;u--;)f=o(f.times(f),h,1);if(null!=i)return g.precision=m,f;if(!(3>d&&t(f.d,h-s,w,d)))return o(f,g.precision=m,w,bn=!0);g.precision=h+=10,r=c=a=new g(1),l=0,d++}f=a}}function m(n,i){var r,s,u,c,a,h,d,l,p,g,w,v=1,N=10,b=n,x=b.d,E=b.constructor,M=E.rounding,y=E.precision;if(b.s<0||!x||!x[0]||!b.e&&1==x[0]&&1==x.length)return new E(x&&!x[0]?-1/0:1!=b.s?NaN:x?0:b);if(null==i?(bn=!1,p=y):p=i,E.precision=p+=N,r=e(x),s=r.charAt(0),!(Math.abs(c=b.e)<15e14))return l=f(E,p+2,y).times(c+""),b=m(new E(s+"."+r.slice(1)),p-N).plus(l),E.precision=y,null==i?o(b,y,M,bn=!0):b;for(;7>s&&1!=s||1==s&&r.charAt(1)>3;)b=b.times(n),r=e(b.d),s=r.charAt(0),v++;for(c=b.e,s>1?(b=new E("0."+r),c++):b=new E(s+"."+r.slice(1)),g=b,d=a=b=Sn(b.minus(1),b.plus(1),p,1),w=o(b.times(b),p,1),u=3;;){if(a=o(a.times(w),p,1),l=d.plus(Sn(a,new E(u),p,1)),e(l.d).slice(0,p)===e(d.d).slice(0,p)){if(d=d.times(2),0!==c&&(d=d.plus(f(E,p+2,y).times(c+""))),d=Sn(d,new E(v),p,1),null!=i)return E.precision=y,d;if(!t(d.d,p-N,M,h))return o(d,E.precision=y,M,bn=!0);E.precision=p+=N,l=a=b=Sn(g.minus(1),g.plus(1),p,1),w=o(b.times(b),p,1),u=h=1}d=l,u+=2}}function v(n){return String(n.s*n.s/0)}function N(n,e){var i,t,r;for((i=e.indexOf("."))>-1&&(e=e.replace(".","")),(t=e.search(/e/i))>0?(0>i&&(i=t),i+=+e.slice(t+1),e=e.substring(0,t)):0>i&&(i=e.length),t=0;48===e.charCodeAt(t);t++);for(r=e.length;48===e.charCodeAt(r-1);--r);if(e=e.slice(t,r)){if(r-=t,n.e=i=i-t-1,n.d=[],t=(i+1)%Rn,0>i&&(t+=Rn),r>t){for(t&&n.d.push(+e.slice(0,t)),r-=Rn;r>t;)n.d.push(+e.slice(t,t+=Rn));e=e.slice(t),t=Rn-e.length}else t-=r;for(;t--;)e+="0";n.d.push(+e),bn&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e0?(a=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),u=o>=0,t=n.constructor,u&&(e=e.replace(".",""),f=e.length,o=f-o,s=l(t,new t(i),o,2*o)),h=r(e,i,Pn),d=h.length-1,o=d;0===h[o];--o)h.pop();return 0>o?new t(0*n.s):(n.e=c(h,d),n.d=h,bn=!1,u&&(n=Sn(n,s,4*f)),a&&(n=n.times(Math.abs(a)<54?Math.pow(2,a):Nn.pow(2,a))),bn=!0,n)}function x(n,e){var i,t=e.d.length;if(3>t)return E(n,2,e,e);i=1.4*Math.sqrt(t),i=i>16?16:0|i,e=e.times(Math.pow(5,-i)),e=E(n,2,e,e);for(var r,s=new n(5),o=new n(16),u=new n(20);i--;)r=e.times(e),e=e.times(s.plus(r.times(o.times(r).minus(u))));return e}function E(n,e,i,t,r){var s,o,u,c,f=1,a=n.precision,h=Math.ceil(a/Rn);for(bn=!1,c=i.times(i),u=new n(t);;){if(o=Sn(u.times(c),new n(e++*e++),a,1),u=r?t.plus(o):t.minus(o),t=Sn(o.times(c),new n(e++*e++),a,1),o=u.plus(t),void 0!==o.d[h]){for(s=h;o.d[s]===u.d[s]&&s--;);if(-1==s)break}s=u,u=t,t=o,o=s,f++}return bn=!0,o.d.length=h+1,o}function M(n,e){var i,t=e.s<0,r=a(n,n.precision,1),s=r.times(.5);if(e=e.abs(),e.lte(s))return ln=t?4:1,e;if(i=e.divToInt(r),i.isZero())ln=t?3:2;else{if(e=e.minus(i.times(r)),e.lte(s))return ln=p(i)?t?2:3:t?4:1,e;ln=p(i)?t?1:4:t?3:2}return e.minus(r).abs()}function y(n,e,t,s){var o,c,f,a,h,d,l,p,g,w=n.constructor,m=void 0!==t;if(m?(i(t,1,gn),void 0===s?s=w.rounding:i(s,0,8)):(t=w.precision,s=w.rounding),n.isFinite()){for(l=u(n),f=l.indexOf("."),m?(o=2,16==e?t=4*t-3:8==e&&(t=3*t-2)):o=e,f>=0&&(l=l.replace(".",""),g=new w(1),g.e=l.length-f,g.d=r(u(g),10,o),g.e=g.d.length),p=r(l,10,o),c=h=p.length;0==p[--h];)p.pop();if(p[0]){if(0>f?c--:(n=new w(n),n.d=p,n.e=c,n=Sn(n,g,t,s,0,o),p=n.d,c=n.e,d=hn),f=p[t],a=o/2,d=d||void 0!==p[t+1],d=4>s?(void 0!==f||d)&&(0===s||s===(n.s<0?3:2)):f>a||f===a&&(4===s||d||6===s&&1&p[t-1]||s===(n.s<0?8:7)),p.length=t,d)for(;++p[--t]>o-1;)p[t]=0,t||(++c,p.unshift(1));for(h=p.length;!p[h-1];--h);for(f=0,l="";h>f;f++)l+=wn.charAt(p[f]);if(m){if(h>1)if(16==e||8==e){for(f=16==e?4:3,--h;h%f;h++)l+="0";for(p=r(l,o,e),h=p.length;!p[h-1];--h);for(f=1,l="1.";h>f;f++)l+=wn.charAt(p[f])}else l=l.charAt(0)+"."+l.slice(1);l=l+(0>c?"p":"p+")+c}else if(0>c){for(;++c;)l="0"+l;l="0."+l}else if(++c>h)for(c-=h;c--;)l+="0";else h>c&&(l=l.slice(0,c)+"."+l.slice(c))}else l=m?"0p+0":"0";l=(16==e?"0x":2==e?"0b":8==e?"0o":"")+l}else l=v(n);return n.s<0?"-"+l:l}function q(n,e){return n.length>e?(n.length=e,!0):void 0}function O(n){return new this(n).abs()}function F(n){return new this(n).acos()}function A(n){return new this(n).acosh()}function D(n,e){return new this(n).plus(e)}function Z(n){return new this(n).asin()}function P(n){return new this(n).asinh()}function R(n){return new this(n).atan()}function L(n){return new this(n).atanh()}function U(n,e){n=new this(n),e=new this(e);var i,t=this.precision,r=this.rounding,s=t+4;return n.s&&e.s?n.d||e.d?!e.d||n.isZero()?(i=e.s<0?a(this,t,r):new this(0),i.s=n.s):!n.d||e.isZero()?(i=a(this,s,1).times(.5),i.s=n.s):e.s<0?(this.precision=s,this.rounding=1,i=this.atan(Sn(n,e,s,1)),e=a(this,s,1),this.precision=t,this.rounding=r,i=n.s<0?i.minus(e):i.plus(e)):i=this.atan(Sn(n,e,s,1)):(i=a(this,s,1).times(e.s>0?.25:.75),i.s=n.s):i=new this(NaN),i}function _(n){return new this(n).cbrt()}function k(n){return o(n=new this(n),n.e+1,2)}function S(n){if(!n||"object"!=typeof n)throw Error(xn+"Object expected");var e,i,t,r=["precision",1,gn,"rounding",0,8,"toExpNeg",-pn,0,"toExpPos",0,pn,"maxE",0,pn,"minE",-pn,0,"modulo",0,9];for(e=0;e=r[e+1]&&t<=r[e+2]))throw Error(En+i+": "+t);this[i]=t}if(void 0!==(t=n[i="crypto"])){if(t!==!0&&t!==!1&&0!==t&&1!==t)throw Error(En+i+": "+t);if(t){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(yn);this[i]=!0}else this[i]=!1}return this}function T(n){return new this(n).cos()}function C(n){return new this(n).cosh()}function I(n){function e(n){var i,t,r,s=this;if(!(s instanceof e))return new e(n);if(s.constructor=e,n instanceof e)return s.s=n.s,s.e=n.e,void(s.d=(n=n.d)?n.slice():n);if(r=typeof n,"number"===r){if(0===n)return s.s=0>1/n?-1:1,s.e=0,void(s.d=[0]);if(0>n?(n=-n,s.s=-1):s.s=1,n===~~n&&1e7>n){for(i=0,t=n;t>=10;t/=10)i++;return s.e=i,void(s.d=[n])}return 0*n!==0?(n||(s.s=NaN),s.e=NaN,void(s.d=null)):N(s,n.toString())}if("string"!==r)throw Error(En+n);return 45===n.charCodeAt(0)?(n=n.slice(1),s.s=-1):s.s=1,Zn.test(n)?N(s,n):b(s,n)}var i,t,r;if(e.prototype=kn,e.ROUND_UP=0,e.ROUND_DOWN=1,e.ROUND_CEIL=2,e.ROUND_FLOOR=3,e.ROUND_HALF_UP=4,e.ROUND_HALF_DOWN=5,e.ROUND_HALF_EVEN=6,e.ROUND_HALF_CEIL=7,e.ROUND_HALF_FLOOR=8,e.EUCLID=9,e.config=e.set=S,e.clone=I,e.abs=O,e.acos=F,e.acosh=A,e.add=D,e.asin=Z,e.asinh=P,e.atan=R,e.atanh=L,e.atan2=U,e.cbrt=_,e.ceil=k,e.cos=T,e.cosh=C,e.div=H,e.exp=B,e.floor=V,e.hypot=$,e.ln=j,e.log=W,e.log10=z,e.log2=J,e.max=G,e.min=K,e.mod=Q,e.mul=X,e.pow=Y,e.random=nn,e.round=en,e.sign=tn,e.sin=rn,e.sinh=sn,e.sqrt=on,e.sub=un,e.tan=cn,e.tanh=fn,e.trunc=an,void 0===n&&(n={}),n)for(r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],i=0;io;)s=e[o],s>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:c[o++]=s%1e7;else{if(!crypto.randomBytes)throw Error(yn);for(e=crypto.randomBytes(r*=4);r>o;)s=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((127&e[o+3])<<24),s>=214e7?crypto.randomBytes(4).copy(e,o):(c.push(s%1e7),o+=4);o=r/4}else for(;r>o;)c[o++]=1e7*Math.random()|0;for(r=c[--o],n%=Rn,r&&n&&(s=On(10,Rn-n),c[o]=(r/s|0)*s);0===c[o];o--)c.pop();if(0>o)t=0,c=[0];else{for(t=-1;0===c[0];t-=Rn)c.shift();for(r=1,s=c[0];s>=10;s/=10)r++;Rn>r&&(t-=Rn-r)}return u.e=t,u.d=c,u}function en(n){return o(n=new this(n),n.e+1,this.rounding)}function tn(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function rn(n){return new this(n).sin()}function sn(n){return new this(n).sinh()}function on(n){return new this(n).sqrt()}function un(n,e){return new this(n).sub(e)}function cn(n){return new this(n).tan()}function fn(n){return new this(n).tanh()}function an(n){return o(n=new this(n),n.e+1,1)}var hn,dn,ln,pn=9e15,gn=1e9,wn="0123456789abcdef",mn="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",vn="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Nn={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-pn,maxE:pn,crypto:!1},bn=!0,xn="[DecimalError] ",En=xn+"Invalid argument: ",Mn=xn+"Precision limit exceeded",yn=xn+"crypto unavailable",qn=Math.floor,On=Math.pow,Fn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,An=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Dn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,Zn=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,Pn=1e7,Rn=7,Ln=9007199254740991,Un=mn.length-1,_n=vn.length-1,kn={};kn.absoluteValue=kn.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),o(n)},kn.ceil=function(){return o(new this.constructor(this),this.e+1,2)},kn.comparedTo=kn.cmp=function(n){var e,i,t,r,s=this,o=s.d,u=(n=new s.constructor(n)).d,c=s.s,f=n.s;if(!o||!u)return c&&f?c!==f?c:o===u?0:!o^0>c?1:-1:NaN;if(!o[0]||!u[0])return o[0]?c:u[0]?-f:0;if(c!==f)return c;if(s.e!==n.e)return s.e>n.e^0>c?1:-1;for(t=o.length,r=u.length,e=0,i=r>t?t:r;i>e;++e)if(o[e]!==u[e])return o[e]>u[e]^0>c?1:-1;return t===r?0:t>r^0>c?1:-1},kn.cosine=kn.cos=function(){var n,e,i=this,t=i.constructor;return i.d?i.d[0]?(n=t.precision,e=t.rounding,t.precision=n+Math.max(i.e,i.sd())+Rn,t.rounding=1,i=s(t,M(t,i)),t.precision=n,t.rounding=e,o(2==ln||3==ln?i.neg():i,n,e,!0)):new t(1):new t(NaN)},kn.cubeRoot=kn.cbrt=function(){var n,i,t,r,s,u,c,f,a,h,d=this,l=d.constructor;if(!d.isFinite()||d.isZero())return new l(d);for(bn=!1,u=d.s*Math.pow(d.s*d,1/3),u&&Math.abs(u)!=1/0?r=new l(u.toString()):(t=e(d.d),n=d.e,(u=(n-t.length+1)%3)&&(t+=1==u||-2==u?"0":"00"),u=Math.pow(t,1/3),n=qn((n+1)/3)-(n%3==(0>n?-1:2)),u==1/0?t="5e"+n:(t=u.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),r=new l(t),r.s=d.s),c=(n=l.precision)+3;;)if(f=r,a=f.times(f).times(f),h=a.plus(d),r=Sn(h.plus(d).times(f),h.plus(a),c+2,1),e(f.d).slice(0,c)===(t=e(r.d)).slice(0,c)){if(t=t.slice(c-3,c+1),"9999"!=t&&(s||"4999"!=t)){(!+t||!+t.slice(1)&&"5"==t.charAt(0))&&(o(r,n+1,1),i=!r.times(r).times(r).eq(d));break}if(!s&&(o(f,n+1,0),f.times(f).times(f).eq(d))){r=f;break}c+=4,s=1}return bn=!0,o(r,n,l.rounding,i)},kn.decimalPlaces=kn.dp=function(){var n,e=this.d,i=NaN;if(e){if(n=e.length-1,i=(n-qn(this.e/Rn))*Rn,n=e[n])for(;n%10==0;n/=10)i--;0>i&&(i=0)}return i},kn.dividedBy=kn.div=function(n){return Sn(this,new this.constructor(n))},kn.dividedToIntegerBy=kn.divToInt=function(n){var e=this,i=e.constructor;return o(Sn(e,new i(n),0,1,1),i.precision,i.rounding)},kn.equals=kn.eq=function(n){return 0===this.cmp(n)},kn.floor=function(){return o(new this.constructor(this),this.e+1,3)},kn.greaterThan=kn.gt=function(n){return this.cmp(n)>0},kn.greaterThanOrEqualTo=kn.gte=function(n){var e=this.cmp(n);return 1==e||0===e},kn.hyperbolicCosine=kn.cosh=function(){var n,e,i,t,r,s=this,u=s.constructor,c=new u(1);if(!s.isFinite())return new u(s.s?1/0:NaN);if(s.isZero())return c;i=u.precision,t=u.rounding,u.precision=i+Math.max(s.e,s.sd())+4,u.rounding=1,r=s.d.length,32>r?(n=Math.ceil(r/3),e=Math.pow(4,-n).toString()):(n=16,e="2.3283064365386962890625e-10"),s=E(u,1,s.times(e),new u(1),!0);for(var f,a=n,h=new u(8);a--;)f=s.times(s),s=c.minus(f.times(h.minus(f.times(h))));return o(s,u.precision=i,u.rounding=t,!0)},kn.hyperbolicSine=kn.sinh=function(){var n,e,i,t,r=this,s=r.constructor;if(!r.isFinite()||r.isZero())return new s(r);if(e=s.precision,i=s.rounding,s.precision=e+Math.max(r.e,r.sd())+4,s.rounding=1,t=r.d.length,3>t)r=E(s,2,r,r,!0);else{n=1.4*Math.sqrt(t),n=n>16?16:0|n,r=r.times(Math.pow(5,-n)),r=E(s,2,r,r,!0);for(var u,c=new s(5),f=new s(16),a=new s(20);n--;)u=r.times(r),r=r.times(c.plus(u.times(f.times(u).plus(a))))}return s.precision=e,s.rounding=i,o(r,e,i,!0)},kn.hyperbolicTangent=kn.tanh=function(){var n,e,i=this,t=i.constructor;return i.isFinite()?i.isZero()?new t(i):(n=t.precision,e=t.rounding,t.precision=n+7,t.rounding=1,Sn(i.sinh(),i.cosh(),t.precision=n,t.rounding=e)):new t(i.s)},kn.inverseCosine=kn.acos=function(){var n,e=this,i=e.constructor,t=e.abs().cmp(1),r=i.precision,s=i.rounding;return-1!==t?0===t?e.isNeg()?a(i,r,s):new i(0):new i(NaN):e.isZero()?a(i,r+4,s).times(.5):(i.precision=r+6,i.rounding=1,e=e.asin(),n=a(i,r+4,s).times(.5),i.precision=r,i.rounding=s,n.minus(e))},kn.inverseHyperbolicCosine=kn.acosh=function(){var n,e,i=this,t=i.constructor;return i.lte(1)?new t(i.eq(1)?0:NaN):i.isFinite()?(n=t.precision,e=t.rounding,t.precision=n+Math.max(Math.abs(i.e),i.sd())+4,t.rounding=1,bn=!1,i=i.times(i).minus(1).sqrt().plus(i),bn=!0,t.precision=n,t.rounding=e,i.ln()):new t(i)},kn.inverseHyperbolicSine=kn.asinh=function(){var n,e,i=this,t=i.constructor;return!i.isFinite()||i.isZero()?new t(i):(n=t.precision,e=t.rounding,t.precision=n+2*Math.max(Math.abs(i.e),i.sd())+6,t.rounding=1,bn=!1,i=i.times(i).plus(1).sqrt().plus(i),bn=!0,t.precision=n,t.rounding=e,i.ln())},kn.inverseHyperbolicTangent=kn.atanh=function(){var n,e,i,t,r=this,s=r.constructor;return r.isFinite()?r.e>=0?new s(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=s.precision,e=s.rounding,t=r.sd(),Math.max(t,n)<2*-r.e-1?o(new s(r),n,e,!0):(s.precision=i=t-r.e,r=Sn(r.plus(1),new s(1).minus(r),i+n,1),s.precision=n+4,s.rounding=1,r=r.ln(),s.precision=n,s.rounding=e,r.times(.5))):new s(NaN)},kn.inverseSine=kn.asin=function(){var n,e,i,t,r=this,s=r.constructor;return r.isZero()?new s(r):(e=r.abs().cmp(1),i=s.precision,t=s.rounding,-1!==e?0===e?(n=a(s,i+4,t).times(.5),n.s=r.s,n):new s(NaN):(s.precision=i+6,s.rounding=1,r=r.div(new s(1).minus(r.times(r)).sqrt().plus(1)).atan(),s.precision=i,s.rounding=t,r.times(2)))},kn.inverseTangent=kn.atan=function(){var n,e,i,t,r,s,u,c,f,h=this,d=h.constructor,l=d.precision,p=d.rounding;if(h.isFinite()){if(h.isZero())return new d(h);if(h.abs().eq(1)&&_n>=l+4)return u=a(d,l+4,p).times(.25),u.s=h.s,u}else{if(!h.s)return new d(NaN);if(_n>=l+4)return u=a(d,l+4,p).times(.5),u.s=h.s,u}for(d.precision=c=l+10,d.rounding=1,i=Math.min(28,c/Rn+2|0),n=i;n;--n)h=h.div(h.times(h).plus(1).sqrt().plus(1));for(bn=!1,e=Math.ceil(c/Rn),t=1,f=h.times(h),u=new d(h),r=h;-1!==n;)if(r=r.times(f),s=u.minus(r.div(t+=2)),r=r.times(f),u=s.plus(r.div(t+=2)),void 0!==u.d[e])for(n=e;u.d[n]===s.d[n]&&n--;);return i&&(u=u.times(2<this.d.length-2},kn.isNaN=function(){return!this.s},kn.isNegative=kn.isNeg=function(){return this.s<0},kn.isPositive=kn.isPos=function(){return this.s>0},kn.isZero=function(){return!!this.d&&0===this.d[0]},kn.lessThan=kn.lt=function(n){return this.cmp(n)<0},kn.lessThanOrEqualTo=kn.lte=function(n){return this.cmp(n)<1},kn.logarithm=kn.log=function(n){var i,r,s,u,c,a,h,d,l=this,p=l.constructor,g=p.precision,w=p.rounding,v=5;if(null==n)n=new p(10),i=!0;else{if(n=new p(n),r=n.d,n.s<0||!r||!r[0]||n.eq(1))return new p(NaN);i=n.eq(10)}if(r=l.d,l.s<0||!r||!r[0]||l.eq(1))return new p(r&&!r[0]?-1/0:1!=l.s?NaN:r?0:1/0);if(i)if(r.length>1)c=!0;else{for(u=r[0];u%10===0;)u/=10;c=1!==u}if(bn=!1,h=g+v,a=m(l,h),s=i?f(p,h+10):m(n,h),d=Sn(a,s,h,1),t(d.d,u=g,w))do if(h+=10,a=m(l,h),s=i?f(p,h+10):m(n,h),d=Sn(a,s,h,1),!c){+e(d.d).slice(u+1,u+15)+1==1e14&&(d=o(d,g+1,0));break}while(t(d.d,u+=10,w));return bn=!0,o(d,g,w)},kn.minus=kn.sub=function(n){var e,i,t,r,s,u,f,a,h,d,l,p,g=this,w=g.constructor;if(n=new w(n),!g.d||!n.d)return g.s&&n.s?g.d?n.s=-n.s:n=new w(n.d||g.s!==n.s?g:NaN):n=new w(NaN),n;if(g.s!=n.s)return n.s=-n.s,g.plus(n);if(h=g.d,p=n.d,f=w.precision,a=w.rounding,!h[0]||!p[0]){if(p[0])n.s=-n.s;else{if(!h[0])return new w(3===a?-0:0);n=new w(g)}return bn?o(n,f,a):n}if(i=qn(n.e/Rn),d=qn(g.e/Rn),h=h.slice(),s=d-i){for(l=0>s,l?(e=h,s=-s,u=p.length):(e=p,i=d,u=h.length),t=Math.max(Math.ceil(f/Rn),u)+2,s>t&&(s=t,e.length=1),e.reverse(),t=s;t--;)e.push(0);e.reverse()}else{for(t=h.length,u=p.length,l=u>t,l&&(u=t),t=0;u>t;t++)if(h[t]!=p[t]){l=h[t]0;--t)h[u++]=0;for(t=p.length;t>s;){if(h[--t]r?(i=h,r=-r,u=d.length):(i=d,t=s,u=h.length),s=Math.ceil(f/Rn),u=s>u?s+1:u+1,r>u&&(r=u,i.length=1),i.reverse();r--;)i.push(0);i.reverse()}for(u=h.length,r=d.length,0>u-r&&(r=u,i=d,d=h,h=i),e=0;r;)e=(h[--r]=h[r]+d[r]+e)/Pn|0,h[r]%=Pn;for(e&&(h.unshift(e),++t),u=h.length;0==h[--u];)h.pop();return n.d=h,n.e=c(h,t),bn?o(n,f,a):n},kn.precision=kn.sd=function(n){var e,i=this;if(void 0!==n&&n!==!!n&&1!==n&&0!==n)throw Error(En+n);return i.d?(e=h(i.d),n&&i.e+1>e&&(e=i.e+1)):e=NaN,e},kn.round=function(){var n=this,e=n.constructor;return o(new e(n),n.e+1,e.rounding)},kn.sine=kn.sin=function(){var n,e,i=this,t=i.constructor;return i.isFinite()?i.isZero()?new t(i):(n=t.precision,e=t.rounding,t.precision=n+Math.max(i.e,i.sd())+Rn,t.rounding=1,i=x(t,M(t,i)),t.precision=n,t.rounding=e,o(ln>2?i.neg():i,n,e,!0)):new t(NaN)},kn.squareRoot=kn.sqrt=function(){var n,i,t,r,s,u,c=this,f=c.d,a=c.e,h=c.s,d=c.constructor;if(1!==h||!f||!f[0])return new d(!h||0>h&&(!f||f[0])?NaN:f?c:1/0);for(bn=!1,h=Math.sqrt(+c),0==h||h==1/0?(i=e(f),(i.length+a)%2==0&&(i+="0"),h=Math.sqrt(i),a=qn((a+1)/2)-(0>a||a%2),h==1/0?i="1e"+a:(i=h.toExponential(),i=i.slice(0,i.indexOf("e")+1)+a),r=new d(i)):r=new d(h.toString()),t=(a=d.precision)+3;;)if(u=r,r=u.plus(Sn(c,u,t+2,1)).times(.5),e(u.d).slice(0,t)===(i=e(r.d)).slice(0,t)){if(i=i.slice(t-3,t+1),"9999"!=i&&(s||"4999"!=i)){(!+i||!+i.slice(1)&&"5"==i.charAt(0))&&(o(r,a+1,1),n=!r.times(r).eq(c));break}if(!s&&(o(u,a+1,0),u.times(u).eq(c))){r=u;break}t+=4,s=1}return bn=!0,o(r,a,d.rounding,n)},kn.tangent=kn.tan=function(){var n,e,i=this,t=i.constructor;return i.isFinite()?i.isZero()?new t(i):(n=t.precision,e=t.rounding,t.precision=n+10,t.rounding=1,i=i.sin(),i.s=1,i=Sn(i,new t(1).minus(i.times(i)).sqrt(),n+10,0),t.precision=n,t.rounding=e,o(2==ln||4==ln?i.neg():i,n,e,!0)):new t(NaN)},kn.times=kn.mul=function(n){var e,i,t,r,s,u,f,a,h,d=this,l=d.constructor,p=d.d,g=(n=new l(n)).d;if(n.s*=d.s,!(p&&p[0]&&g&&g[0]))return new l(!n.s||p&&!p[0]&&!g||g&&!g[0]&&!p?NaN:p&&g?0*n.s:n.s/0);for(i=qn(d.e/Rn)+qn(n.e/Rn),a=p.length,h=g.length,h>a&&(s=p,p=g,g=s,u=a,a=h,h=u),s=[],u=a+h,t=u;t--;)s.push(0);for(t=h;--t>=0;){for(e=0,r=a+t;r>t;)f=s[r]+g[t]*p[r-t-1]+e,s[r--]=f%Pn|0,e=f/Pn|0;s[r]=(s[r]+e)%Pn|0}for(;!s[--u];)s.pop();return e?++i:s.shift(),n.d=s,n.e=c(s,i),bn?o(n,l.precision,l.rounding):n},kn.toBinary=function(n,e){return y(this,2,n,e)},kn.toDecimalPlaces=kn.toDP=function(n,e){var t=this,r=t.constructor;return t=new r(t),void 0===n?t:(i(n,0,gn),void 0===e?e=r.rounding:i(e,0,8),o(t,n+t.e+1,e))},kn.toExponential=function(n,e){var t,r=this,s=r.constructor;return void 0===n?t=u(r,!0):(i(n,0,gn),void 0===e?e=s.rounding:i(e,0,8),r=o(new s(r),n+1,e),t=u(r,!0,n+1)),r.isNeg()&&!r.isZero()?"-"+t:t},kn.toFixed=function(n,e){var t,r,s=this,c=s.constructor;return void 0===n?t=u(s):(i(n,0,gn),void 0===e?e=c.rounding:i(e,0,8),r=o(new c(s),n+s.e+1,e),t=u(r,!1,n+r.e+1)),s.isNeg()&&!s.isZero()?"-"+t:t},kn.toFraction=function(n){var i,t,r,s,o,u,c,f,a,d,l,p,g=this,w=g.d,m=g.constructor;if(!w)return new m(g);if(a=t=new m(1),r=f=new m(0),i=new m(r),o=i.e=h(w)-g.e-1,u=o%Rn,i.d[0]=On(10,0>u?Rn+u:u),null==n)n=o>0?i:a;else{if(c=new m(n),!c.isInt()||c.lt(a))throw Error(En+c);n=c.gt(i)?o>0?i:a:c}for(bn=!1,c=new m(e(w)),d=m.precision,m.precision=o=w.length*Rn*2;l=Sn(c,i,0,1,1),s=t.plus(l.times(r)),1!=s.cmp(n);)t=r,r=s,s=a,a=f.plus(l.times(s)),f=s,s=i,i=c.minus(l.times(s)),c=s;return s=Sn(n.minus(t),r,0,1,1),f=f.plus(s.times(a)),t=t.plus(s.times(r)),f.s=a.s=g.s,p=Sn(a,r,o,1).minus(g).abs().cmp(Sn(f,t,o,1).minus(g).abs())<1?[a,r]:[f,t],m.precision=d,bn=!0,p},kn.toHexadecimal=kn.toHex=function(n,e){return y(this,16,n,e)},kn.toNearest=function(n,e){var t=this,r=t.constructor;if(t=new r(t),null==n){if(!t.d)return t;n=new r(1),e=r.rounding}else{if(n=new r(n),void 0!==e&&i(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(bn=!1,4>e&&(e=[4,5,7,8][e]),t=Sn(t,n,0,e,1).times(n),bn=!0,o(t)):(n.s=t.s,t=n),t},kn.toNumber=function(){return+this},kn.toOctal=function(n,e){return y(this,8,n,e)},kn.toPower=kn.pow=function(n){var i,r,s,u,c,f,a,h=this,d=h.constructor,p=+(n=new d(n));if(!(h.d&&n.d&&h.d[0]&&n.d[0]))return new d(On(+h,p));if(h=new d(h),h.eq(1))return h;if(s=d.precision,c=d.rounding,n.eq(1))return o(h,s,c);if(i=qn(n.e/Rn),r=n.d.length-1,a=i>=r,f=h.s,a){if((r=0>p?-p:p)<=Ln)return u=l(d,h,r,s),n.s<0?new d(1).div(u):o(u,s,c)}else if(0>f)return new d(NaN);return f=0>f&&1&n.d[Math.max(i,r)]?-1:1,r=On(+h,p),i=0!=r&&isFinite(r)?new d(r+"").e:qn(p*(Math.log("0."+e(h.d))/Math.LN10+h.e+1)),i>d.maxE+1||i0?f/0:0):(bn=!1,d.rounding=h.s=1,r=Math.min(12,(i+"").length),u=w(n.times(m(h,s+r)),s),u=o(u,s+5,1),t(u.d,s,c)&&(i=s+10,u=o(w(n.times(m(h,i+r)),i),i+5,1),+e(u.d).slice(s+1,s+15)+1==1e14&&(u=o(u,s+1,0))),u.s=f,bn=!0,d.rounding=c,o(u,s,c))},kn.toPrecision=function(n,e){var t,r=this,s=r.constructor;return void 0===n?t=u(r,r.e<=s.toExpNeg||r.e>=s.toExpPos):(i(n,1,gn),void 0===e?e=s.rounding:i(e,0,8),r=o(new s(r),n,e),t=u(r,n<=r.e||r.e<=s.toExpNeg,n)),r.isNeg()&&!r.isZero()?"-"+t:t},kn.toSignificantDigits=kn.toSD=function(n,e){var t=this,r=t.constructor;return void 0===n?(n=r.precision,e=r.rounding):(i(n,1,gn),void 0===e?e=r.rounding:i(e,0,8)),o(new r(t),n,e)},kn.toString=function(){var n=this,e=n.constructor,i=u(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+i:i},kn.truncated=kn.trunc=function(){return o(new this.constructor(this),this.e+1,1)},kn.valueOf=kn.toJSON=function(){var n=this,e=n.constructor,i=u(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+i:i};var Sn=function(){function n(n,e,i){var t,r=0,s=n.length;for(n=n.slice();s--;)t=n[s]*e+r,n[s]=t%i|0,r=t/i|0;return r&&n.unshift(r),n}function e(n,e,i,t){var r,s;if(i!=t)s=i>t?1:-1;else for(r=s=0;i>r;r++)if(n[r]!=e[r]){s=n[r]>e[r]?1:-1;break}return s}function i(n,e,i,t){for(var r=0;i--;)n[i]-=r,r=n[i]1;)n.shift()}return function(t,r,s,u,c,f){var a,h,d,l,p,g,w,m,v,N,b,x,E,M,y,q,O,F,A,D,Z=t.constructor,P=t.s==r.s?1:-1,R=t.d,L=r.d;if(!(R&&R[0]&&L&&L[0]))return new Z(t.s&&r.s&&(R?!L||R[0]!=L[0]:L)?R&&0==R[0]||!L?0*P:P/0:NaN);for(f?(p=1,h=t.e-r.e):(f=Pn,p=Rn,h=qn(t.e/p)-qn(r.e/p)),A=L.length,O=R.length,v=new Z(P),N=v.d=[],d=0;L[d]==(R[d]||0);d++);if(L[d]>(R[d]||0)&&h--,null==s?(M=s=Z.precision,u=Z.rounding):M=c?s+(t.e-r.e)+1:s,0>M)N.push(1),g=!0;else{if(M=M/p+2|0,d=0,1==A){for(l=0,L=L[0],M++;(O>d||l)&&M--;d++)y=l*f+(R[d]||0),N[d]=y/L|0,l=y%L|0;g=l||O>d}else{for(l=f/(L[0]+1)|0,l>1&&(L=n(L,l,f),R=n(R,l,f),A=L.length,O=R.length),q=A,b=R.slice(0,A),x=b.length;A>x;)b[x++]=0;D=L.slice(),D.unshift(0),F=L[0],L[1]>=f/2&&++F;do l=0,a=e(L,b,A,x),0>a?(E=b[0],A!=x&&(E=E*f+(b[1]||0)),l=E/F|0,l>1?(l>=f&&(l=f-1),w=n(L,l,f),m=w.length,x=b.length,a=e(w,b,m,x),1==a&&(l--,i(w,m>A?D:L,m,f))):(0==l&&(a=l=1),w=L.slice()),m=w.length,x>m&&w.unshift(0),i(b,w,x,f),-1==a&&(x=b.length,a=e(L,b,A,x),1>a&&(l++,i(b,x>A?D:L,x,f))),x=b.length):0===a&&(l++,b=[0]),N[d++]=l,a&&b[0]?b[x++]=R[q]||0:(b=[R[q]],x=1);while((q++=10;l/=10)d++;v.e=d+h*p-1,o(v,c?s+v.e+1:s,u,g)}return v}}();Nn=I(Nn),mn=new Nn(mn),vn=new Nn(vn),"function"==typeof define&&define.amd?define(function(){return Nn}):"undefined"!=typeof module&&module.exports?module.exports=Nn["default"]=Nn.Decimal=Nn:(n||(n="undefined"!=typeof self&&self&&self.self==self?self:Function("return this")()),dn=n.Decimal,Nn.noConflict=function(){return n.Decimal=dn,Nn},n.Decimal=Nn)}(this); -//# sourceMappingURL=doc/decimal.js.map \ No newline at end of file + +> decimal.js@7.2.1 build /home/rainger/projects/workspace/decimal.js +> uglifyjs decimal.js --source-map doc/decimal.js.map -c -m -o decimal.min.js --preamble "/* decimal.js v7.2.1 https://github.com/MikeMcl/decimal.js/LICENCE */" + +/*! 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;tn)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(;un-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.e0?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)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(;++s17)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,g=m.d,y=m.constructor,b=y.rounding,w=y.precision;if(m.s<0||!g||!g[0]||!m.e&&g[0]==1&&g.length==1)return new y(g&&!g[0]?-1/0:m.s!=1?NaN:g?0:m);t==null?(l=!1,c=w):c=t,y.precision=c+=v,n=k(g),r=n.charAt(0);if(!(Math.abs(s=m.e)<15e14))return f=B(y,c+2,w).times(s+""),m=W(new y(r+"."+n.slice(1)),c-v).plus(f),y.precision=w,t==null?D(m,w,b,l=!0):m;while(r<7&&r!=1||r==1&&n.charAt(1)>3)m=m.times(e),n=k(m.d),r=n.charAt(0),d++;s=m.e,r>1?(m=new y("0."+n),s++):m=new y(r+"."+n.slice(1)),h=m,a=o=m=_(m.minus(1),m.plus(1),c,1),p=D(m.times(m),c,1),i=3;for(;;){o=D(o.times(p),c,1),f=a.plus(_(o,new y(i),c,1));if(k(f.d).slice(0,c)===k(a.d).slice(0,c)){a=a.times(2),s!==0&&(a=a.plus(B(y,c+2,w).times(s+""))),a=_(a,new y(d),c,1);if(t!=null)return y.precision=w,a;if(!A(a.d,c-v,b,u))return D(a,y.precision=w,b,l=!0);y.precision=c+=v,f=o=m=_(h.minus(1),h.plus(1),c,1),p=D(m.times(m),c,1),i=u=1}a=f,i+=2}}function X(e){return String(e.s*e.s/0)}function V(e,t){var n,r,i;(n=t.indexOf("."))>-1&&(t=t.replace(".","")),(r=t.search(/e/i))>0?(n<0&&(n=r),n+=+t.slice(r+1),t=t.substring(0,r)):n<0&&(n=t.length);for(r=0;t.charCodeAt(r)===48;r++);for(i=t.length;t.charCodeAt(i-1)===48;--i);t=t.slice(r,i);if(t){i-=r,e.e=n=n-r-1,e.d=[],r=(n+1)%S,n<0&&(r+=S);if(re.constructor.maxE?(e.d=null,e.e=NaN):e.e0?(f=+t.slice(s+1),t=t.substring(2,s)):t=t.slice(2),s=t.indexOf("."),u=s>=0,r=e.constructor,u&&(t=t.replace(".",""),a=t.length,s=a-s,i=q(r,new r(n),s,s*2)),c=O(t,n,E),p=c.length-1;for(s=p;c[s]===0;--s)c.pop();return s<0?new r(e.s*0):(e.e=H(c,p),e.d=c,l=!1,u&&(e=_(e,i,a*4)),f&&(e=e.times(Math.abs(f)<54?Math.pow(2,f):o.pow(2,f))),l=!0,e)}function J(e,t){var n,r=t.d.length;if(r<3)return K(e,2,t,t);n=1.4*Math.sqrt(r),n=n>16?16:n|0,t=t.times(Math.pow(5,-n)),t=K(e,2,t,t);var i,s=new e(5),o=new e(16),u=new e(20);for(;n--;)i=t.times(t),t=t.times(s.plus(i.times(o.times(i).minus(u))));return t}function K(e,t,n,r,i){var s,o,u,a,f=1,c=e.precision,h=Math.ceil(c/S);l=!1,a=n.times(n),u=new e(r);for(;;){o=_(u.times(a),new e(t++*t++),c,1),u=i?r.plus(o):r.minus(o),r=_(o.times(a),new e(t++*t++),c,1),o=u.plus(r);if(o.d[h]!==void 0){for(s=h;o.d[s]===u.d[s]&&s--;);if(s==-1)break}s=u,u=r,r=o,o=s,f++}return l=!0,o.d.length=h+1,o}function Q(e,t){var n,r=t.s<0,i=j(e,e.precision,1),s=i.times(.5);t=t.abs();if(t.lte(s))return f=r?4:1,t;n=t.divToInt(i);if(n.isZero())f=r?3:2;else{t=t.minus(n.times(i));if(t.lte(s))return f=R(n)?r?2:3:r?4:1,t;f=R(n)?r?1:4:r?3:2}return t.minus(i).abs()}function G(e,t,i,s){var o,a,f,l,c,h,p,d,v,m=e.constructor,g=i!==void 0;g?(L(i,1,n),s===void 0?s=m.rounding:L(s,0,8)):(i=m.precision,s=m.rounding);if(!e.isFinite())p=X(e);else{p=P(e),f=p.indexOf("."),g?(o=2,t==16?i=i*4-3:t==8&&(i=i*3-2)):o=t,f>=0&&(p=p.replace(".",""),v=new m(1),v.e=p.length-f,v.d=O(P(v),10,o),v.e=v.d.length),d=O(p,10,o),a=c=d.length;for(;d[--c]==0;)d.pop();if(!d[0])p=g?"0p+0":"0";else{f<0?a--:(e=new m(e),e.d=d,e.e=a,e=_(e,v,i,s,0,o),d=e.d,a=e.e,h=u),f=d[i],l=o/2,h=h||d[i+1]!==void 0,h=s<4?(f!==void 0||h)&&(s===0||s===(e.s<0?3:2)):f>l||f===l&&(s===4||h||s===6&&d[i-1]&1||s===(e.s<0?8:7)),d.length=i;if(h)for(;++d[--i]>o-1;)d[i]=0,i||(++a,d=[1].concat(d));for(c=d.length;!d[c-1];--c);for(f=0,p="";f1)if(t==16||t==8){f=t==16?4:3;for(--c;c%f;c++)p+="0";d=O(p,o,t);for(c=d.length;!d[c-1];--c);for(f=1,p="1.";fc)for(a-=c;a--;)p+="0";else at)return e.length=t,!0}function Z(e){return(new this(e)).abs()}function et(e){return(new this(e)).acos()}function tt(e){return(new this(e)).acosh()}function nt(e,t){return(new this(e)).plus(t)}function rt(e){return(new this(e)).asin()}function it(e){return(new this(e)).asinh()}function st(e){return(new this(e)).atan()}function ot(e){return(new this(e)).atanh()}function ut(e,t){e=new this(e),t=new this(t);var n,r=this.precision,i=this.rounding,s=r+4;return!e.s||!t.s?n=new this(NaN):!e.d&&!t.d?(n=j(this,s,1).times(t.s>0?.25:.75),n.s=e.s):!t.d||e.isZero()?(n=t.s<0?j(this,r,i):new this(0),n.s=e.s):!e.d||t.isZero()?(n=j(this,s,1).times(.5),n.s=e.s):t.s<0?(this.precision=s,this.rounding=1,n=this.atan(_(e,t,s,1)),t=j(this,s,1),this.precision=r,this.rounding=i,n=e.s<0?n.minus(t):n.plus(t)):n=this.atan(_(e,t,s,1)),n}function at(e){return(new this(e)).cbrt()}function ft(e){return D(e=new this(e),e.e+1,2)}function lt(e){if(!e||typeof e!="object")throw Error(c+"Object expected");var r,i,s,o=["precision",1,n,"rounding",0,8,"toExpNeg",-t,0,"toExpPos",0,t,"maxE",0,t,"minE",-t,0,"modulo",0,9];for(r=0;r=o[r+1]&&s<=o[r+2]))throw Error(h+i+": "+s);this[i]=s}if((s=e[i="crypto"])!==void 0){if(s!==!0&&s!==!1&&s!==0&&s!==1)throw Error(h+i+": "+s);if(s){if(typeof crypto=="undefined"||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(d);this[i]=!0}else this[i]=!1}return this}function ct(e){return(new this(e)).cos()}function ht(e){return(new this(e)).cosh()}function pt(e){function i(e){var t,n,r,s=this;if(s instanceof i){s.constructor=i;if(e instanceof i){s.s=e.s,s.e=e.e,s.d=(e=e.d)?e.slice():e;return}r=typeof e;if(r==="number"){if(e===0){s.s=1/e<0?-1:1,s.e=0,s.d=[0];return}e<0?(e=-e,s.s=-1):s.s=1;if(e===~~e&&e<1e7){for(t=0,n=e;n>=10;n/=10)t++;s.e=t,s.d=[e];return}if(e*0!==0){e||(s.s=NaN),s.e=NaN,s.d=null;return}return V(s,e.toString())}if(r!=="string")throw Error(h+e);return e.charCodeAt(0)===45?(e=e.slice(1),s.s=-1):s.s=1,w.test(e)?V(s,e):$(s,e)}return new i(e)}var t,n,r;i.prototype=C,i.ROUND_UP=0,i.ROUND_DOWN=1,i.ROUND_CEIL=2,i.ROUND_FLOOR=3,i.ROUND_HALF_UP=4,i.ROUND_HALF_DOWN=5,i.ROUND_HALF_EVEN=6,i.ROUND_HALF_CEIL=7,i.ROUND_HALF_FLOOR=8,i.EUCLID=9,i.config=i.set=lt,i.clone=pt,i.abs=Z,i.acos=et,i.acosh=tt,i.add=nt,i.asin=rt,i.asinh=it,i.atan=st,i.atanh=ot,i.atan2=ut,i.cbrt=at,i.ceil=ft,i.cos=ct,i.cosh=ht,i.div=dt,i.exp=vt,i.floor=mt,i.hypot=gt,i.ln=yt,i.log=bt,i.log10=Et,i.log2=wt,i.max=St,i.min=xt,i.mod=Tt,i.mul=Nt,i.pow=Ct,i.random=kt,i.round=Lt,i.sign=At,i.sin=Ot,i.sinh=Mt,i.sqrt=_t,i.sub=Dt,i.tan=Pt,i.tanh=Ht,i.trunc=Bt,e===void 0&&(e={});if(e){r=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"];for(t=0;t=429e7?t[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=s%1e7}else{if(!crypto.randomBytes)throw Error(d);t=crypto.randomBytes(i*=4);for(;o=214e7?crypto.randomBytes(4).copy(t,o):(a.push(s%1e7),o+=4);o=i/4}i=a[--o],e%=S,i&&e&&(s=m(10,S-e),a[o]=(i/s|0)*s);for(;a[o]===0;o--)a.pop();if(o<0)r=0,a=[0];else{r=-1;for(;a[0]===0;r-=S)a.splice(0,1);for(i=1,s=a[0];s>=10;s/=10)i++;ie.e^a<0?1:-1;r=o.length,i=u.length;for(t=0,n=ru[t]^a<0?1:-1;return r===i?0:r>i^a<0?1:-1},C.cosine=C.cos=function(){var e,t,n=this,r=n.constructor;return n.d?n.d[0]?(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+S,r.rounding=1,n=M(r,Q(r,n)),r.precision=e,r.rounding=t,D(f==2||f==3?n.neg():n,e,t,!0)):new r(1):new r(NaN)},C.cubeRoot=C.cbrt=function(){var e,t,n,r,i,s,o,u,a,f,c=this,h=c.constructor;if(!c.isFinite()||c.isZero())return new h(c);l=!1,s=c.s*Math.pow(c.s*c,1/3);if(!s||Math.abs(s)==1/0){n=k(c.d),e=c.e;if(s=(e-n.length+1)%3)n+=s==1||s==-2?"0":"00";s=Math.pow(n,1/3),e=v((e+1)/3)-(e%3==(e<0?-1:2)),s==1/0?n="5e"+e:(n=s.toExponential(),n=n.slice(0,n.indexOf("e")+1)+e),r=new h(n),r.s=c.s}else r=new h(s.toString());o=(e=h.precision)+3;for(;;){u=r,a=u.times(u).times(u),f=a.plus(c),r=_(f.plus(c).times(u),f.plus(a),o+2,1);if(k(u.d).slice(0,o)===(n=k(r.d)).slice(0,o)){n=n.slice(o-3,o+1);if(!(n=="9999"||!i&&n=="4999")){if(!+n||!+n.slice(1)&&n.charAt(0)=="5")D(r,e+1,1),t=!r.times(r).times(r).eq(c);break}if(!i){D(u,e+1,0);if(u.times(u).times(u).eq(c)){r=u;break}}o+=4,i=1}}return l=!0,D(r,e,h.rounding,t)},C.decimalPlaces=C.dp=function(){var e,t=this.d,n=NaN;if(t){e=t.length-1,n=(e-v(this.e/S))*S,e=t[e];if(e)for(;e%10==0;e/=10)n--;n<0&&(n=0)}return n},C.dividedBy=C.div=function(e){return _(this,new this.constructor(e))},C.dividedToIntegerBy=C.divToInt=function(e){var t=this,n=t.constructor;return D(_(t,new n(e),0,1,1),n.precision,n.rounding)},C.equals=C.eq=function(e){return this.cmp(e)===0},C.floor=function(){return D(new this.constructor(this),this.e+1,3)},C.greaterThan=C.gt=function(e){return this.cmp(e)>0},C.greaterThanOrEqualTo=C.gte=function(e){var t=this.cmp(e);return t==1||t===0},C.hyperbolicCosine=C.cosh=function(){var e,t,n,r,i,s=this,o=s.constructor,u=new o(1);if(!s.isFinite())return new o(s.s?1/0:NaN);if(s.isZero())return u;n=o.precision,r=o.rounding,o.precision=n+Math.max(s.e,s.sd())+4,o.rounding=1,i=s.d.length,i<32?(e=Math.ceil(i/3),t=Math.pow(4,-e).toString()):(e=16,t="2.3283064365386962890625e-10"),s=K(o,1,s.times(t),new o(1),!0);var a,f=e,l=new o(8);for(;f--;)a=s.times(s),s=u.minus(a.times(l.minus(a.times(l))));return D(s,o.precision=n,o.rounding=r,!0)},C.hyperbolicSine=C.sinh=function(){var e,t,n,r,i=this,s=i.constructor;if(!i.isFinite()||i.isZero())return new s(i);t=s.precision,n=s.rounding,s.precision=t+Math.max(i.e,i.sd())+4,s.rounding=1,r=i.d.length;if(r<3)i=K(s,2,i,i,!0);else{e=1.4*Math.sqrt(r),e=e>16?16:e|0,i=i.times(Math.pow(5,-e)),i=K(s,2,i,i,!0);var o,u=new s(5),a=new s(16),f=new s(20);for(;e--;)o=i.times(i),i=i.times(u.plus(o.times(a.times(o).plus(f))))}return s.precision=t,s.rounding=n,D(i,t,n,!0)},C.hyperbolicTangent=C.tanh=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+7,r.rounding=1,_(n.sinh(),n.cosh(),r.precision=e,r.rounding=t)):new r(n.s)},C.inverseCosine=C.acos=function(){var e,t=this,n=t.constructor,r=t.abs().cmp(1),i=n.precision,s=n.rounding;return r!==-1?r===0?t.isNeg()?j(n,i,s):new n(0):new n(NaN):t.isZero()?j(n,i+4,s).times(.5):(n.precision=i+6,n.rounding=1,t=t.asin(),e=j(n,i+4,s).times(.5),n.precision=i,n.rounding=s,e.minus(t))},C.inverseHyperbolicCosine=C.acosh=function(){var e,t,n=this,r=n.constructor;return n.lte(1)?new r(n.eq(1)?0:NaN):n.isFinite()?(e=r.precision,t=r.rounding,r.precision=e+Math.max(Math.abs(n.e),n.sd())+4,r.rounding=1,l=!1,n=n.times(n).minus(1).sqrt().plus(n),l=!0,r.precision=e,r.rounding=t,n.ln()):new r(n)},C.inverseHyperbolicSine=C.asinh=function(){var e,t,n=this,r=n.constructor;return!n.isFinite()||n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+2*Math.max(Math.abs(n.e),n.sd())+6,r.rounding=1,l=!1,n=n.times(n).plus(1).sqrt().plus(n),l=!0,r.precision=e,r.rounding=t,n.ln())},C.inverseHyperbolicTangent=C.atanh=function(){var e,t,n,r,i=this,s=i.constructor;return i.isFinite()?i.e>=0?new s(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(e=s.precision,t=s.rounding,r=i.sd(),Math.max(r,e)<2*-i.e-1?D(new s(i),e,t,!0):(s.precision=n=r-i.e,i=_(i.plus(1),(new s(1)).minus(i),n+e,1),s.precision=e+4,s.rounding=1,i=i.ln(),s.precision=e,s.rounding=t,i.times(.5))):new s(NaN)},C.inverseSine=C.asin=function(){var e,t,n,r,i=this,s=i.constructor;return i.isZero()?new s(i):(t=i.abs().cmp(1),n=s.precision,r=s.rounding,t!==-1?t===0?(e=j(s,n+4,r).times(.5),e.s=i.s,e):new s(NaN):(s.precision=n+6,s.rounding=1,i=i.div((new s(1)).minus(i.times(i)).sqrt().plus(1)).atan(),s.precision=n,s.rounding=r,i.times(2)))},C.inverseTangent=C.atan=function(){var e,t,n,r,i,s,o,u,a,f=this,c=f.constructor,h=c.precision,p=c.rounding;if(!f.isFinite()){if(!f.s)return new c(NaN);if(h+4<=N)return o=j(c,h+4,p).times(.5),o.s=f.s,o}else{if(f.isZero())return new c(f);if(f.abs().eq(1)&&h+4<=N)return o=j(c,h+4,p).times(.25),o.s=f.s,o}c.precision=u=h+10,c.rounding=1,n=Math.min(28,u/S+2|0);for(e=n;e;--e)f=f.div(f.times(f).plus(1).sqrt().plus(1));l=!1,t=Math.ceil(u/S),r=1,a=f.times(f),o=new c(f),i=f;for(;e!==-1;){i=i.times(a),s=o.minus(i.div(r+=2)),i=i.times(a),o=s.plus(i.div(r+=2));if(o.d[t]!==void 0)for(e=t;o.d[e]===s.d[e]&&e--;);}return n&&(o=o.times(2<this.d.length-2},C.isNaN=function(){return!this.s},C.isNegative=C.isNeg=function(){return this.s<0},C.isPositive=C.isPos=function(){return this.s>0},C.isZero=function(){return!!this.d&&this.d[0]===0},C.lessThan=C.lt=function(e){return this.cmp(e)<0},C.lessThanOrEqualTo=C.lte=function(e){return this.cmp(e)<1},C.logarithm=C.log=function(e){var t,n,r,i,s,o,u,a,f=this,c=f.constructor,h=c.precision,p=c.rounding,d=5;if(e==null)e=new c(10),t=!0;else{e=new c(e),n=e.d;if(e.s<0||!n||!n[0]||e.eq(1))return new c(NaN);t=e.eq(10)}n=f.d;if(f.s<0||!n||!n[0]||f.eq(1))return new c(n&&!n[0]?-1/0:f.s!=1?NaN:n?0:1/0);if(t)if(n.length>1)s=!0;else{for(i=n[0];i%10===0;)i/=10;s=i!==1}l=!1,u=h+d,o=W(f,u),r=t?B(c,u+10):W(e,u),a=_(o,r,u,1);if(A(a.d,i=h,p))do{u+=10,o=W(f,u),r=t?B(c,u+10):W(e,u),a=_(o,r,u,1);if(!s){+k(a.d).slice(i+1,i+15)+1==1e14&&(a=D(a,h+1,0));break}}while(A(a.d,i+=10,p));return l=!0,D(a,h,p)},C.minus=C.sub=function(e){var t,n,r,i,s,o,u,a,f,c,h,p,d=this,m=d.constructor;e=new m(e);if(!d.d||!e.d)return!d.s||!e.s?e=new m(NaN):d.d?e.s=-e.s:e=new m(e.d||d.s!==e.s?d:NaN),e;if(d.s!=e.s)return e.s=-e.s,d.plus(e);f=d.d,p=e.d,u=m.precision,a=m.rounding;if(!f[0]||!p[0]){if(p[0])e.s=-e.s;else{if(!f[0])return new m(a===3?0:0);e=new m(d)}return l?D(e,u,a):e}n=v(e.e/S),c=v(d.e/S),f=f.slice(),s=c-n;if(s){h=s<0,h?(t=f,s=-s,o=p.length):(t=p,n=c,o=f.length),r=Math.max(Math.ceil(u/S),o)+2,s>r&&(s=r,t.length=1),t.reverse();for(r=s;r--;)t.push(0);t.reverse()}else{r=f.length,o=p.length,h=r0;--r)f[o++]=0;for(r=p.length;r>s;){if(f[--r]o?s+1:o+1,i>o&&(i=o,n.length=1),n.reverse();for(;i--;)n.push(0);n.reverse()}o=f.length,i=c.length,o-i<0&&(i=o,n=c,c=f,f=n);for(t=0;i;)t=(f[--i]=f[i]+c[i]+t)/E|0,f[i]%=E;t&&(f=[t].concat(f),++r);for(o=f.length;f[--o]==0;)f.pop();return e.d=f,e.e=H(f,r),l?D(e,u,a):e},C.precision=C.sd=function(e){var t,n=this;if(e!==void 0&&e!==!!e&&e!==1&&e!==0)throw Error(h+e);return n.d?(t=F(n.d),e&&n.e+1>t&&(t=n.e+1)):t=NaN,t},C.round=function(){var e=this,t=e.constructor;return D(new t(e),e.e+1,t.rounding)},C.sine=C.sin=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+Math.max(n.e,n.sd())+S,r.rounding=1,n=J(r,Q(r,n)),r.precision=e,r.rounding=t,D(f>2?n.neg():n,e,t,!0)):new r(NaN)},C.squareRoot=C.sqrt=function(){var e,t,n,r,i,s,o=this,u=o.d,a=o.e,f=o.s,c=o.constructor;if(f!==1||!u||!u[0])return new c(!f||f<0&&(!u||u[0])?NaN:u?o:1/0);l=!1,f=Math.sqrt(+o),f==0||f==1/0?(t=k(u),(t.length+a)%2==0&&(t+="0"),f=Math.sqrt(t),a=v((a+1)/2)-(a<0||a%2),f==1/0?t="1e"+a:(t=f.toExponential(),t=t.slice(0,t.indexOf("e")+1)+a),r=new c(t)):r=new c(f.toString()),n=(a=c.precision)+3;for(;;){s=r,r=s.plus(_(o,s,n+2,1)).times(.5);if(k(s.d).slice(0,n)===(t=k(r.d)).slice(0,n)){t=t.slice(n-3,n+1);if(!(t=="9999"||!i&&t=="4999")){if(!+t||!+t.slice(1)&&t.charAt(0)=="5")D(r,a+1,1),e=!r.times(r).eq(o);break}if(!i){D(s,a+1,0);if(s.times(s).eq(o)){r=s;break}}n+=4,i=1}}return l=!0,D(r,a,c.rounding,e)},C.tangent=C.tan=function(){var e,t,n=this,r=n.constructor;return n.isFinite()?n.isZero()?new r(n):(e=r.precision,t=r.rounding,r.precision=e+10,r.rounding=1,n=n.sin(),n.s=1,n=_(n,(new r(1)).minus(n.times(n)).sqrt(),e+10,0),r.precision=e,r.rounding=t,D(f==2||f==4?n.neg():n,e,t,!0)):new r(NaN)},C.times=C.mul=function(e){var t,n,r,i,s,o,u,a,f,c=this,h=c.constructor,p=c.d,d=(e=new h(e)).d;e.s*=c.s;if(!p||!p[0]||!d||!d[0])return new h(!e.s||p&&!p[0]&&!d||d&&!d[0]&&!p?NaN:!p||!d?e.s/0:e.s*0);n=v(c.e/S)+v(e.e/S),a=p.length,f=d.length,a=0;){t=0;for(i=a+r;i>r;)u=s[i]+d[r]*p[i-r-1]+t,s[i--]=u%E|0,t=u/E|0;s[i]=(s[i]+t)%E|0}for(;!s[--o];)s.pop();return t?++n:s.splice(0,1),e.d=s,e.e=H(s,n),l?D(e,h.precision,h.rounding):e},C.toBinary=function(e,t){return G(this,2,e,t)},C.toDecimalPlaces=C.toDP=function(e,t){var r=this,i=r.constructor;return r=new i(r),e===void 0?r:(L(e,0,n),t===void 0?t=i.rounding:L(t,0,8),D(r,e+r.e+1,t))},C.toExponential=function(e,t){var r,i=this,s=i.constructor;return e===void 0?r=P(i,!0):(L(e,0,n),t===void 0?t=s.rounding:L(t,0,8),i=D(new s(i),e+1,t),r=P(i,!0,e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},C.toFixed=function(e,t){var r,i,s=this,o=s.constructor;return e===void 0?r=P(s):(L(e,0,n),t===void 0?t=o.rounding:L(t,0,8),i=D(new o(s),e+s.e+1,t),r=P(i,!1,e+i.e+1)),s.isNeg()&&!s.isZero()?"-"+r:r},C.toFraction=function(e){var t,n,r,i,s,o,u,a,f,c,p,d,v=this,g=v.d,y=v.constructor;if(!g)return new y(v);f=n=new y(1),r=a=new y(0),t=new y(r),s=t.e=F(g)-v.e-1,o=s%S,t.d[0]=m(10,o<0?S+o:o);if(e==null)e=s>0?t:f;else{u=new y(e);if(!u.isInt()||u.lt(f))throw Error(h+u);e=u.gt(t)?s>0?t:f:u}l=!1,u=new y(k(g)),c=y.precision,y.precision=s=g.length*S*2;for(;;){p=_(u,t,0,1,1),i=n.plus(p.times(r));if(i.cmp(e)==1)break;n=r,r=i,i=f,f=a.plus(p.times(i)),a=i,i=t,t=u.minus(p.times(i)),u=i}return i=_(e.minus(n),r,0,1,1),a=a.plus(i.times(f)),n=n.plus(i.times(r)),a.s=f.s=v.s,d=_(f,r,s,1).minus(v).abs().cmp(_(a,n,s,1).minus(v).abs())<1?[f,r]:[a,n],y.precision=c,l=!0,d},C.toHexadecimal=C.toHex=function(e,t){return G(this,16,e,t)},C.toNearest=function(e,t){var n=this,r=n.constructor;n=new r(n);if(e==null){if(!n.d)return n;e=new r(1),t=r.rounding}else{e=new r(e),t!==void 0&&L(t,0,8);if(!n.d)return e.s?n:e;if(!e.d)return e.s&&(e.s=n.s),e}return e.d[0]?(l=!1,t<4&&(t=[4,5,7,8][t]),n=_(n,e,0,t,1).times(e),l=!0,D(n)):(e.s=n.s,n=e),n},C.toNumber=function(){return+this},C.toOctal=function(e,t){return G(this,8,e,t)},C.toPower=C.pow=function(e){var t,n,r,i,s,o,u,a=this,f=a.constructor,c=+(e=new f(e));if(!a.d||!e.d||!a.d[0]||!e.d[0])return new f(m(+a,c));a=new f(a);if(a.eq(1))return a;r=f.precision,s=f.rounding;if(e.eq(1))return D(a,r,s);t=v(e.e/S),n=e.d.length-1,u=t>=n,o=a.s;if(!u){if(o<0)return new f(NaN)}else if((n=c<0?-c:c)<=x)return i=q(f,a,n,r),e.s<0?(new f(1)).div(i):D(i,r,s);return o=o<0&&e.d[Math.max(t,n)]&1?-1:1,n=m(+a,c),t=n==0||!isFinite(n)?v(c*(Math.log("0."+k(a.d))/Math.LN10+a.e+1)):(new f(n+"")).e,t>f.maxE+1||t0?o/0:0):(l=!1,f.rounding=a.s=1,n=Math.min(12,(t+"").length),i=z(e.times(W(a,r+n)),r),i=D(i,r+5,1),A(i.d,r,s)&&(t=r+10,i=D(z(e.times(W(a,t+n)),t),t+5,1),+k(i.d).slice(r+1,r+15)+1==1e14&&(i=D(i,r+1,0))),i.s=o,l=!0,f.rounding=s,D(i,r,s))},C.toPrecision=function(e,t){var r,i=this,s=i.constructor;return e===void 0?r=P(i,i.e<=s.toExpNeg||i.e>=s.toExpPos):(L(e,1,n),t===void 0?t=s.rounding:L(t,0,8),i=D(new s(i),e,t),r=P(i,e<=i.e||i.e<=s.toExpNeg,e)),i.isNeg()&&!i.isZero()?"-"+r:r},C.toSignificantDigits=C.toSD=function(e,t){var r=this,i=r.constructor;return e===void 0?(e=i.precision,t=i.rounding):(L(e,1,n),t===void 0?t=i.rounding:L(t,0,8)),D(new i(r),e,t)},C.toString=function(){var e=this,t=e.constructor,n=P(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()&&!e.isZero()?"-"+n:n},C.truncated=C.trunc=function(){return D(new this.constructor(this),this.e+1,1)},C.valueOf=C.toJSON=function(){var e=this,t=e.constructor,n=P(e,e.e<=t.toExpNeg||e.e>=t.toExpPos);return e.isNeg()?"-"+n:n};var _=function(){function e(e,t,n){var r,i=0,s=e.length;for(e=e.slice();s--;)r=e[s]*t+i,e[s]=r%n|0,i=r/n|0;return i&&(e=[i].concat(e)),e}function t(e,t,n,r){var i,s;if(n!=r)s=n>r?1:-1;else for(i=s=0;it[i]?1:-1;break}return s}function n(e,t,n,r){var i=0;for(;n--;)e[n]-=i,i=e[n]1;)e.splice(0,1)}return function(r,i,s,o,a,f){var l,c,h,p,d,m,g,y,b,w,x,T,N,C,k,L,A,O,M,_,P=r.constructor,H=r.s==i.s?1:-1,B=r.d,j=i.d;if(!B||!B[0]||!j||!j[0])return new P(!r.s||!i.s||(B?j&&B[0]==j[0]:!j)?NaN:B&&B[0]==0||!j?H*0:H/0);f?(d=1,c=r.e-i.e):(f=E,d=S,c=v(r.e/d)-v(i.e/d)),M=j.length,A=B.length,b=new P(H),w=b.d=[];for(h=0;j[h]==(B[h]||0);h++);j[h]>(B[h]||0)&&c--,s==null?(C=s=P.precision,o=P.rounding):a?C=s+(r.e-i.e)+1:C=s;if(C<0)w.push(1),m=!0;else{C=C/d+2|0,h=0;if(M==1){p=0,j=j[0],C++;for(;(h1&&(j=e(j,p,f),B=e(B,p,f),M=j.length,A=B.length),L=M,x=B.slice(0,M),T=x.length;for(;T=f/2&&++O;do p=0,l=t(j,x,M,T),l<0?(N=x[0],M!=T&&(N=N*f+(x[1]||0)),p=N/O|0,p>1?(p>=f&&(p=f-1),g=e(j,p,f),y=g.length,T=x.length,l=t(g,x,y,T),l==1&&(p--,n(g,M=10;p/=10)h++;b.e=h+c*d-1,D(b,a?s+b.e+1:s,o,m)}return b}}();o=pt(o),i=new o(i),s=new o(s),typeof define=="function"&&define.amd?define(function(){return o}):typeof module!="undefined"&&module.exports?module.exports=o["default"]=o.Decimal=o:(e||(e=typeof self!="undefined"&&self&&self.self==self?self:Function("return this")()),a=e.Decimal,o.noConflict=function(){return e.Decimal=a,o},e.Decimal=o)})(this); \ No newline at end of file