bignumber.js
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1,2 +0,2 @@ | ||
/*! bignumber.js v2.0.1 https://github.com/MikeMcl/bignumber.js/LICENCE */ | ||
/*! bignumber.js v2.0.2 https://github.com/MikeMcl/bignumber.js/LICENCE */ | ||
(function(n){"use strict";function it(n){function a(n,i){var h,e,f,s,o,r,u=this;if(!(u instanceof a))return ht&<(26,"constructor call without new",n),new a(n,i);if(i!=null&&ot(i,2,64,st,"base")){if(i=i|0,r=n+"",i==10)return u=new a(n instanceof a?n:r),at(u,yt+u.e+1,ct);if((s=typeof n=="number")&&n*0!=0||!new RegExp("^-?"+(h="["+b.slice(0,i)+"]+")+"(?:\\."+h+")?$",i<37?"i":"").test(r))return y(u,r,s,i);s?(u.s=1/n<0?(r=r.slice(1),-1):1,ht&&r.replace(/^0\.0*|\./,"").length>15&<(st,tt,n),s=!1):u.s=r.charCodeAt(0)===45?(r=r.slice(1),-1):1;r=fi(r,10,i,u.s)}else{if(n instanceof a){u.s=n.s;u.e=n.e;u.c=(n=n.c)?n.slice():n;st=0;return}if((s=typeof n=="number")&&n*0==0){if(u.s=1/n<0?(n=-n,-1):1,n===~~n){for(e=0,f=n;f>=10;f/=10,e++);u.e=e;u.c=[n];st=0;return}r=n+""}else{if(!ut.test(r=n+""))return y(u,r,s);u.s=r.charCodeAt(0)===45?(r=r.slice(1),-1):1}}for((e=r.indexOf("."))>-1&&(r=r.replace(".","")),(f=r.search(/e/i))>0?(e<0&&(e=f),e+=+r.slice(f+1),r=r.substring(0,f)):e<0&&(e=r.length),f=0;r.charCodeAt(f)===48;f++);for(o=r.length;r.charCodeAt(--o)===48;);if(r=r.slice(f,o+1),r)if(o=r.length,s&&ht&&o>15&<(st,tt,u.s*n),e=e-f-1,e>pt)u.c=u.e=null;else if(e<gt)u.c=[u.e=0];else{if(u.e=e,u.c=[],f=(e+1)%t,e<0&&(f+=t),f<o){for(f&&u.c.push(+r.slice(0,f)),o-=t;f<o;)u.c.push(+r.slice(f,f+=t));r=r.slice(f);f=t-r.length}else f-=o;for(;f--;r+="0");u.c.push(+r)}else u.c=[u.e=0];st=0}function fi(n,t,i,r){var e,v,o,l,f,u,p,h=n.indexOf("."),w=yt,y=ct;for(i<37&&(n=n.toLowerCase()),h>=0&&(o=bt,bt=0,n=n.replace(".",""),p=new a(i),f=p.pow(n.length-h),bt=o,p.c=rt(c(s(f.c),f.e),10,t),p.e=p.c.length),u=rt(n,i,t),v=o=u.length;u[--o]==0;u.pop());if(!u[0])return"0";if(h<0?--v:(f.c=u,f.e=v,f.s=r,f=vt(f,p,w,y,t),u=f.c,l=f.r,v=f.e),e=v+w+1,h=u[e],o=t/2,l=l||e<0||u[e+1]!=null,l=y<4?(h!=null||l)&&(y==0||y==(f.s<0?3:2)):h>o||h==o&&(y==4||l||y==6&&u[e-1]&1||y==(f.s<0?8:7)),e<1||!u[0])n=l?c("1",-w):"0";else{if(u.length=e,l)for(--t;++u[--e]>t;)u[e]=0,e||(++v,u.unshift(1));for(o=u.length;!u[--o];);for(h=0,n="";h<=o;n+=b.charAt(u[h++]));n=c(n,v)}return n}function ri(n,t,i,r){var h,f,o,e,u;if(i=i!=null&&ot(i,0,8,r,w)?i|0:ct,!n.c)return n.toString();if(h=n.c[0],o=n.e,t==null)u=s(n.c),u=r==19||r==24&&o<=dt?g(u,o):c(u,o);else if(n=at(new a(n),t,i),f=n.e,u=s(n.c),e=u.length,r==19||r==24&&(t<=f||f<=dt)){for(;e<t;u+="0",e++);u=g(u,f)}else if(t-=o,u=c(u,f),f+1>e){if(--t>0)for(u+=".";t--;u+="0");}else if(t+=f-e,t>0)for(f+1==e&&(u+=".");t--;u+="0");return n.s<0&&h?"-"+u:u}function ei(n,t){var i,r,u=0;for(d(n[0])&&(n=n[0]),i=new a(n[0]);++u<n.length;)if(r=new a(n[u]),r.s)t.call(i,r)&&(i=r);else{i=r;break}return i}function oi(n,t,i,r,u){return(n<t||n>i||n!=nt(n))&<(r,(u||"decimal places")+(n<t||n>i?" out of range":" not an integer"),n),!0}function ui(n,i,r){for(var f=1,u=i.length;!i[--u];i.pop());for(u=i[0];u>=10;u/=10,f++);return(r=f+r*t-1)>pt?n.c=n.e=null:r<gt?n.c=[n.e=0]:(n.e=r,n.c=i),n}function lt(n,t,i){var r=new Error(["new BigNumber","cmp","config","div","divToInt","eq","gt","gte","lt","lte","minus","mod","plus","precision","random","round","shift","times","toDigits","toExponential","toFixed","toFormat","toFraction","pow","toPrecision","toString","BigNumber"][n]+"() "+t+": "+i);r.name="BigNumber Error";st=0;throw r;}function at(n,i,r,u){var a,h,s,c,y,l,w,o=n.c,p=k;if(o){n:{for(a=1,c=o[0];c>=10;c/=10,a++);if(h=i-a,h<0)h+=t,s=i,y=o[l=0],w=y/p[a-s-1]%10|0;else if(l=v((h+1)/t),l>=o.length)if(u){for(;o.length<=l;o.push(0));y=w=0;a=1;h%=t;s=h-t+1}else break n;else{for(y=c=o[l],a=1;c>=10;c/=10,a++);h%=t;s=h-t+a;w=s<0?0:y/p[a-s-1]%10|0}if(u=u||i<0||o[l+1]!=null||(s<0?y:y%p[a-s-1]),u=r<4?(w||u)&&(r==0||r==(n.s<0?3:2)):w>5||w==5&&(r==4||u||r==6&&(h>0?s>0?y/p[a-s]:0:o[l-1])%10&1||r==(n.s<0?8:7)),i<1||!o[0])return o.length=0,u?(i-=n.e+1,o[0]=p[i%t],n.e=-i||0):o[0]=n.e=0,n;if(h==0?(o.length=l,c=1,l--):(o.length=l+1,c=p[t-h],o[l]=s>0?e(y/p[a-s]%p[s])*c:0),u)for(;;)if(l==0){for(h=1,s=o[0];s>=10;s/=10,h++);for(s=o[0]+=c,c=1;s>=10;s/=10,c++);h!=c&&(n.e++,o[0]==f&&(o[0]=1));break}else{if(o[l]+=c,o[l]!=f)break;o[l--]=0;c=1}for(h=o.length;o[--h]===0;o.pop());}n.e>pt?n.c=n.e=null:n.e<gt&&(n.c=[n.e=0])}return n}var vt,st=0,et=a.prototype,wt=new a(1),yt=20,ct=4,dt=-7,ni=21,gt=-1e7,pt=1e7,ht=!0,ot=oi,ti=!1,ii=1,bt=100,kt={decimalSeparator:".",groupSeparator:",",groupSize:3,secondaryGroupSize:0,fractionGroupSeparator:" ",fractionGroupSize:0};return a.another=it,a.ROUND_UP=0,a.ROUND_DOWN=1,a.ROUND_CEIL=2,a.ROUND_FLOOR=3,a.ROUND_HALF_UP=4,a.ROUND_HALF_DOWN=5,a.ROUND_HALF_EVEN=6,a.ROUND_HALF_CEIL=7,a.ROUND_HALF_FLOOR=8,a.EUCLID=9,a.config=function(){var n,t,s=0,u={},o=arguments,e=o[0],f=e&&typeof e=="object"?function(){if(e.hasOwnProperty(t))return(n=e[t])!=null}:function(){if(o.length>s)return(n=o[s++])!=null};return f(t="DECIMAL_PLACES")&&ot(n,0,i,2,t)&&(yt=n|0),u[t]=yt,f(t="ROUNDING_MODE")&&ot(n,0,8,2,t)&&(ct=n|0),u[t]=ct,f(t="EXPONENTIAL_AT")&&(d(n)?ot(n[0],-i,0,2,t)&&ot(n[1],0,i,2,t)&&(dt=n[0]|0,ni=n[1]|0):ot(n,-i,i,2,t)&&(dt=-(ni=(n<0?-n:n)|0))),u[t]=[dt,ni],f(t="RANGE")&&(d(n)?ot(n[0],-i,-1,2,t)&&ot(n[1],1,i,2,t)&&(gt=n[0]|0,pt=n[1]|0):ot(n,-i,i,2,t)&&(n|0?gt=-(pt=(n<0?-n:n)|0):ht&<(2,t+" cannot be zero",n))),u[t]=[gt,pt],f(t="ERRORS")&&(n===!!n||n===1||n===0?(st=0,ot=(ht=!!n)?oi:ft):ht&<(2,t+p,n)),u[t]=ht,f(t="CRYPTO")&&(n===!!n||n===1||n===0?(ti=!!(n&&r&&typeof r=="object"),n&&!ti&&ht&<(2,"crypto unavailable",r)):ht&<(2,t+p,n)),u[t]=ti,f(t="MODULO_MODE")&&ot(n,0,9,2,t)&&(ii=n|0),u[t]=ii,f(t="POW_PRECISION")&&ot(n,0,i,2,t)&&(bt=n|0),u[t]=bt,f(t="FORMAT")&&(typeof n=="object"?kt=n:ht&<(2,t+" not an object",n)),u[t]=kt,u},a.max=function(){return ei(arguments,et.lt)},a.min=function(){return ei(arguments,et.gt)},a.random=function(){var n=9007199254740992,u=Math.random()*n&2097151?function(){return e(Math.random()*n)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(n){var s,y,l,c,o,f=0,h=[],p=new a(wt);if(n=n==null||!ot(n,0,i,14)?yt:n|0,c=v(n/t),ti)if(r&&r.getRandomValues){for(s=r.getRandomValues(new Uint32Array(c*=2));f<c;)o=s[f]*131072+(s[f+1]>>>11),o>=9e15?(y=r.getRandomValues(new Uint32Array(2)),s[f]=y[0],s[f+1]=y[1]):(h.push(o%1e14),f+=2);f=c/2}else if(r&&r.randomBytes){for(s=r.randomBytes(c*=7);f<c;)o=(s[f]&31)*281474976710656+s[f+1]*1099511627776+s[f+2]*4294967296+s[f+3]*16777216+(s[f+4]<<16)+(s[f+5]<<8)+s[f+6],o>=9e15?r.randomBytes(7).copy(s,f):(h.push(o%1e14),f+=7);f=c/7}else ht&<(14,"crypto unavailable",r);if(!f)for(;f<c;)o=u(),o<9e15&&(h[f++]=o%1e14);for(c=h[--f],n%=t,c&&n&&(o=k[t-n],h[f]=e(c/o)*o);h[f]===0;h.pop(),f--);if(f<0)h=[l=0];else{for(l=-1;h[0]===0;h.shift(),l-=t);for(f=1,o=h[0];o>=10;o/=10,f++);f<t&&(l-=t-f)}return p.e=l,p.c=h,p}}(),vt=function(){function n(n,t,i){var f,e,s,h,r=0,u=n.length,c=t%o,l=t/o|0;for(n=n.slice();u--;)s=n[u]%o,h=n[u]/o|0,f=l*s+h*c,e=c*s+f%o*o+r,r=(e/i|0)+(f/o|0)+l*h,n[u]=e%i;return r&&n.unshift(r),n}function i(n,t,i,r){var u,f;if(i!=r)f=i>r?1:-1;else for(u=f=0;u<i;u++)if(n[u]!=t[u]){f=n[u]>t[u]?1:-1;break}return f}function r(n,t,i,r){for(var u=0;i--;)n[i]-=u,u=n[i]<t[i]?1:0,n[i]=u*r+n[i]-t[i];for(;!n[0]&&n.length>1;n.shift());}return function(o,s,h,c,l){var g,rt,d,et,p,tt,ut,it,ft,y,w,ot,st,ct,lt,nt,ht,k=o.s==s.s?1:-1,b=o.c,v=s.c;if(!b||!b[0]||!v||!v[0])return new a(!o.s||!s.s||(b?v&&b[0]==v[0]:!v)?NaN:b&&b[0]==0||!v?k*0:k/0);for(it=new a(k),ft=it.c=[],rt=o.e-s.e,k=h+rt+1,l||(l=f,rt=u(o.e/t)-u(s.e/t),k=k/t|0),d=0;v[d]==(b[d]||0);d++);if(v[d]>(b[d]||0)&&rt--,k<0)ft.push(1),et=!0;else{for(ct=b.length,nt=v.length,d=0,k+=2,p=e(l/(v[0]+1)),p>1&&(v=n(v,p,l),b=n(b,p,l),nt=v.length,ct=b.length),st=nt,y=b.slice(0,nt),w=y.length;w<nt;y[w++]=0);ht=v.slice();ht.unshift(0);lt=v[0];v[1]>=l/2&<++;do p=0,g=i(v,y,nt,w),g<0?(ot=y[0],nt!=w&&(ot=ot*l+(y[1]||0)),p=e(ot/lt),p>1?(p>=l&&(p=l-1),tt=n(v,p,l),ut=tt.length,w=y.length,g=i(tt,y,ut,w),g==1&&(p--,r(tt,nt<ut?ht:v,ut,l))):(p==0&&(g=p=1),tt=v.slice()),ut=tt.length,ut<w&&tt.unshift(0),r(y,tt,w,l),g==-1&&(w=y.length,g=i(v,y,nt,w),g<1&&(p++,r(y,nt<w?ht:v,w,l))),w=y.length):g===0&&(p++,y=[0]),ft[d++]=p,g&&y[0]?y[w++]=b[st]||0:(y=[b[st]],w=1);while((st++<ct||y[0]!=null)&&k--);et=y[0]!=null;ft[0]||ft.shift()}if(l==f){for(d=1,k=ft[0];k>=10;k/=10,d++);at(it,h+(it.e=d+rt*t-1)+1,c,et)}else it.e=rt,it.r=+et;return it}}(),y=function(){var n=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,i=/^\.([^.]+)$/,r=/^-?(Infinity|NaN)$/,u=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(f,e,o,s){var c,h=o?e:e.replace(u,"");if(r.test(h))f.s=isNaN(h)?null:h<0?-1:1;else{if(!o&&(h=h.replace(n,function(n,t,i){return c=(i=i.toLowerCase())=="x"?16:i=="b"?2:8,!s||s==c?t:n}),s&&(c=s,h=h.replace(t,"$1").replace(i,"0.$1")),e!=h))return new a(h,c);ht&<(st,"not a"+(s?" base "+s:"")+" number",e);f.s=null}f.c=f.e=null;st=0}}(),et.absoluteValue=et.abs=function(){var n=new a(this);return n.s<0&&(n.s=1),n},et.ceil=function(){return at(new a(this),this.e+1,2)},et.comparedTo=et.cmp=function(n,t){return st=1,l(this,new a(n,t))},et.decimalPlaces=et.dp=function(){var n,i,r=this.c;if(!r)return null;if(n=((i=r.length-1)-u(this.e/t))*t,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},et.dividedBy=et.div=function(n,t){return st=3,vt(this,new a(n,t),yt,ct)},et.dividedToIntegerBy=et.divToInt=function(n,t){return st=4,vt(this,new a(n,t),0,1)},et.equals=et.eq=function(n,t){return st=5,l(this,new a(n,t))===0},et.floor=function(){return at(new a(this),this.e+1,3)},et.greaterThan=et.gt=function(n,t){return st=6,l(this,new a(n,t))>0},et.greaterThanOrEqualTo=et.gte=function(n,t){return st=7,(t=l(this,new a(n,t)))===1||t===0},et.isFinite=function(){return!!this.c},et.isInteger=et.isInt=function(){return!!this.c&&u(this.e/t)>this.c.length-2},et.isNaN=function(){return!this.s},et.isNegative=et.isNeg=function(){return this.s<0},et.isZero=function(){return!!this.c&&this.c[0]==0},et.lessThan=et.lt=function(n,t){return st=8,l(this,new a(n,t))<0},et.lessThanOrEqualTo=et.lte=function(n,t){return st=9,(t=l(this,new a(n,t)))===-1||t===0},et.minus=et.sub=function(n,i){var h,s,c,p,v=this,o=v.s;if(st=10,n=new a(n,i),i=n.s,!o||!i)return new a(NaN);if(o!=i)return n.s=-i,v.plus(n);var y=v.e/t,l=n.e/t,r=v.c,e=n.c;if(!y||!l){if(!r||!e)return r?(n.s=-i,n):new a(e?v:NaN);if(!r[0]||!e[0])return e[0]?(n.s=-i,n):new a(r[0]?v:ct==3?-0:0)}if(y=u(y),l=u(l),r=r.slice(),o=y-l){for((p=o<0)?(o=-o,c=r):(l=y,c=e),c.reverse(),i=o;i--;c.push(0));c.reverse()}else for(s=(p=(o=r.length)<(i=e.length))?o:i,o=i=0;i<s;i++)if(r[i]!=e[i]){p=r[i]<e[i];break}if(p&&(c=r,r=e,e=c,n.s=-n.s),i=(s=e.length)-(h=r.length),i>0)for(;i--;r[h++]=0);for(i=f-1;s>o;){if(r[--s]<e[s]){for(h=s;h&&!r[--h];r[h]=i);--r[h];r[s]+=f}r[s]-=e[s]}for(;r[0]==0;r.shift(),--l);return r[0]?ui(n,r,l):(n.s=ct==3?-1:1,n.c=[n.e=0],n)},et.modulo=et.mod=function(n,t){var r,u,i=this;if(st=11,n=new a(n,t),i.c&&n.s&&(!n.c||n.c[0])){if(!n.c||i.c&&!i.c[0])return new a(i)}else return new a(NaN);return ii==9?(u=n.s,n.s=1,r=vt(i,n,0,3),n.s=u,r.s*=u):r=vt(i,n,0,ii),i.minus(r.times(n))},et.negated=et.neg=function(){var n=new a(this);return n.s=-n.s||null,n},et.plus=et.add=function(n,i){var s,c=this,r=c.s;if(st=12,n=new a(n,i),i=n.s,!r||!i)return new a(NaN);if(r!=i)return n.s=-i,c.minus(n);var l=c.e/t,h=n.e/t,e=c.c,o=n.c;if(!l||!h){if(!e||!o)return new a(r/0);if(!e[0]||!o[0])return o[0]?n:new a(e[0]?c:r*0)}if(l=u(l),h=u(h),e=e.slice(),r=l-h){for(r>0?(h=l,s=o):(r=-r,s=e),s.reverse();r--;s.push(0));s.reverse()}for(r=e.length,i=o.length,r-i<0&&(s=o,o=e,e=s,i=r),r=0;i;)r=(e[--i]=e[i]+o[i]+r)/f|0,e[i]%=f;return r&&(e.unshift(r),++h),ui(n,e,h)},et.precision=et.sd=function(n){var r,i,f=this,u=f.c;if(n!=null&&n!==!!n&&n!==1&&n!==0&&(ht&<(13,"argument"+p,n),n!=!!n&&(n=null)),!u)return null;if(i=u.length-1,r=i*t+1,i=u[i]){for(;i%10==0;i/=10,r--);for(i=u[0];i>=10;i/=10,r++);}return n&&f.e+1>r&&(r=f.e+1),r},et.round=function(n,t){var r=new a(this);return(n==null||ot(n,0,i,15))&&at(r,~~n+this.e+1,t==null||!ot(t,0,8,15,w)?ct:t|0),r},et.shift=function(n){var t=this;return ot(n,-h,h,16,"argument")?t.times("1e"+nt(n)):new a(t.c&&t.c[0]&&(n<-h||n>h)?t.s*(n<0?0:1/0):t)},et.squareRoot=et.sqrt=function(){var l,t,i,h,f,e=this,o=e.c,n=e.s,r=e.e,c=yt+4,v=new a("0.5");if(n!==1||!o||!o[0])return new a(!n||n<0&&(!o||o[0])?NaN:o?e:1/0);if(n=Math.sqrt(+e),n==0||n==1/0?(t=s(o),(t.length+r)%2==0&&(t+="0"),n=Math.sqrt(t),r=u((r+1)/2)-(r<0||r%2),n==1/0?t="1e"+r:(t=n.toExponential(),t=t.slice(0,t.indexOf("e")+1)+r),i=new a(t)):i=new a(n+""),i.c[0])for(r=i.e,n=r+c,n<3&&(n=0);;)if(f=i,i=v.times(f.plus(vt(e,f,c,1))),s(f.c).slice(0,n)===(t=s(i.c)).slice(0,n))if(i.e<r&&--n,t=t.slice(n-3,n+1),t!="9999"&&(h||t!="4999")){+t&&(+t.slice(1)||t.charAt(0)!="5")||(at(i,i.e+yt+2,1),l=!i.times(i).eq(e));break}else{if(!h&&(at(f,f.e+yt+2,0),f.times(f).eq(e))){i=f;break}c+=4;n+=4;h=1}return at(i,i.e+yt+1,ct,l)},et.times=et.mul=function(n,i){var p,d,s,w,k,g,l,v,nt,y,tt,it,h,rt,c,b=this,r=b.c,e=(st=17,n=new a(n,i)).c;if(!r||!e||!r[0]||!e[0])return b.s&&n.s&&(!r||r[0]||e)&&(!e||e[0]||r)?(n.s*=b.s,r&&e?(n.c=[0],n.e=0):n.c=n.e=null):n.c=n.e=n.s=null,n;for(d=u(b.e/t)+u(n.e/t),n.s*=b.s,l=r.length,y=e.length,l<y&&(h=r,r=e,e=h,s=l,l=y,y=s),s=l+y,h=[];s--;h.push(0));for(rt=f,c=o,s=y;--s>=0;){for(p=0,tt=e[s]%c,it=e[s]/c|0,k=l,w=s+k;w>s;)v=r[--k]%c,nt=r[k]/c|0,g=it*v+nt*tt,v=tt*v+g%c*c+h[w]+p,p=(v/rt|0)+(g/c|0)+it*nt,h[w--]=v%rt;h[w]=p}return p?++d:h.shift(),ui(n,h,d)},et.toDigits=function(n,t){var r=new a(this);return n=n==null||!ot(n,1,i,18,"precision")?null:n|0,t=t==null||!ot(t,0,8,18,w)?ct:t|0,n?at(r,n,t):r},et.toExponential=function(n,t){return ri(this,n!=null&&ot(n,0,i,19)?~~n+1:null,t,19)},et.toFixed=function(n,t){return ri(this,n!=null&&ot(n,0,i,20)?~~n+this.e+1:null,t,20)},et.toFormat=function(n,t){var h=ri(this,n!=null&&ot(n,0,i,21)?~~n+this.e+1:null,t,21);if(this.c){var r,l=h.split("."),f=+kt.groupSize,e=+kt.secondaryGroupSize,a=kt.groupSeparator,u=l[0],c=l[1],v=this.s<0,o=v?u.slice(1):u,s=o.length;if(e&&(r=f,f=e,e=r,s-=r),f>0&&s>0){for(r=s%f||f,u=o.substr(0,r);r<s;r+=f)u+=a+o.substr(r,f);e>0&&(u+=a+o.slice(r));v&&(u="-"+u)}h=c?u+kt.decimalSeparator+((e=+kt.fractionGroupSize)?c.replace(new RegExp("\\d{"+e+"}\\B","g"),"$&"+kt.fractionGroupSeparator):c):u}return h},et.toFraction=function(n){var b,f,r,c,v,i,u,y,w,p=ht,l=this,d=l.c,e=new a(wt),o=f=new a(wt),h=u=new a(wt);if(n!=null&&(ht=!1,i=new a(n),ht=p,(p=i.isInt())&&!i.lt(wt)||(ht&<(22,"max denominator "+(p?"out of range":"not an integer"),n),n=!p&&i.c&&at(i,i.e+1,1).gte(wt)?i:null)),!d)return l.toString();for(w=s(d),c=e.e=w.length-l.e-1,e.c[0]=k[(v=c%t)<0?t+v:v],n=!n||i.cmp(e)>0?c>0?e:o:i,v=pt,pt=1/0,i=new a(w),u.c[0]=0;;){if(y=vt(i,e,0,1),r=f.plus(y.times(h)),r.cmp(n)==1)break;f=h;h=r;o=u.plus(y.times(r=o));u=r;e=i.minus(y.times(r=e));i=r}return r=vt(n.minus(f),h,0,1),u=u.plus(r.times(o)),f=f.plus(r.times(h)),u.s=o.s=l.s,c*=2,b=vt(o,h,c,ct).minus(l).abs().cmp(vt(u,f,c,ct).minus(l).abs())<1?[o.toString(),h.toString()]:[u.toString(),f.toString()],pt=v,b},et.toNumber=function(){var n=this;return+n||(n.s?n.s*0:NaN)},et.toPower=et.pow=function(n){var r,i,f=e(n<0?-n:+n),u=this;if(!ot(n,-h,h,23,"exponent")&&(!isFinite(n)||f>h&&(n/=0)||parseFloat(n)!=n&&!(n=NaN)))return new a(Math.pow(+u,n));for(r=bt?v(bt/t+2):0,i=new a(wt);;){if(f%2){if(i=i.times(u),!i.c)break;r&&i.c.length>r&&(i.c.length=r)}if(f=e(f/2),!f)break;u=u.times(u);r&&u.c&&u.c.length>r&&(u.c.length=r)}return n<0&&(i=wt.div(i)),r?at(i,bt,ct):i},et.toPrecision=function(n,t){return ri(this,n!=null&&ot(n,1,i,24,"precision")?n|0:null,t,24)},et.toString=function(n){var t,r=this,u=r.s,i=r.e;return i===null?u?(t="Infinity",u<0&&(t="-"+t)):t="NaN":(t=s(r.c),t=n!=null&&ot(n,2,64,25,"base")?fi(c(t,i),n|0,10,u):i<=dt||i>=ni?g(t,i):c(t,i),u<0&&r.c[0]&&(t="-"+t)),t},et.truncated=et.trunc=function(){return at(new a(this),this.e+1,1)},et.valueOf=et.toJSON=function(){return this.toString()},n!=null&&a.config(n),a}function u(n){var t=n|0;return n>0||n===t?t:t-1}function s(n){for(var i,f,e=1,r=n.length,u=n[0]+"";e<r;){for(i=n[e++]+"",f=t-i.length;f--;i="0"+i);u+=i}for(r=u.length;u.charCodeAt(--r)===48;);return u.slice(0,r+1||1)}function l(n,t){var r,f,u=n.c,e=t.c,i=n.s,h=t.s,o=n.e,s=t.e;if(!i||!h)return null;if(r=u&&!u[0],f=e&&!e[0],r||f)return r?f?0:-h:i;if(i!=h)return i;if(r=i<0,f=o==s,!u||!e)return f?0:!u^r?1:-1;if(!f)return o>s^r?1:-1;for(h=(o=u.length)<(s=e.length)?o:s,i=0;i<h;i++)if(u[i]!=e[i])return u[i]>e[i]^r?1:-1;return o==s?0:o>s^r?1:-1}function ft(n,t,i){return(n=nt(n))>=t&&n<=i}function d(n){return Object.prototype.toString.call(n)=="[object Array]"}function rt(n,t,i){for(var u,r=[0],f,e=0,o=n.length;e<o;){for(f=r.length;f--;r[f]*=t);for(r[u=0]+=b.indexOf(n.charAt(e++));u<r.length;u++)r[u]>i-1&&(r[u+1]==null&&(r[u+1]=0),r[u+1]+=r[u]/i|0,r[u]%=i)}return r.reverse()}function g(n,t){return(n.length>1?n.charAt(0)+"."+n.slice(1):n)+(t<0?"e":"e+")+t}function c(n,t){var r,i;if(t<0){for(i="0.";++t;i+="0");n=i+n}else if(r=n.length,++t>r){for(i="0",t-=r;--t;i+="0");n+=i}else t<r&&(n=n.slice(0,t)+"."+n.slice(t));return n}function nt(n){return n=parseFloat(n),n<0?v(n):e(n)}var a,r,y,ut=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,v=Math.ceil,e=Math.floor,p=" not a boolean or binary digit",w="rounding mode",tt="number type has more than 15 significant digits",b="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",f=1e14,t=14,h=9007199254740991,k=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],o=1e7,i=1e9;if(a=it(),typeof define=="function"&&define.amd)define(function(){return a});else if(typeof module!="undefined"&&module.exports){if(module.exports=a,!r)try{r=require("crypto")}catch(et){}}else n.BigNumber=a})(this) |
{ | ||
"name": "bignumber.js", | ||
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"keywords": [ | ||
@@ -34,4 +34,4 @@ "arbitrary", | ||
"test": "node ./test/every-test.js", | ||
"build": "uglifyjs bignumber.js -c -m -o bignumber.min.js --preamble '/* bignumber.js v2.0.1 https://github.com/MikeMcl/bignumber.js/LICENCE */'" | ||
"build": "uglifyjs bignumber.js -c -m -o bignumber.min.js --preamble '/* bignumber.js v2.0.2 https://github.com/MikeMcl/bignumber.js/LICENCE */'" | ||
} | ||
} |
@@ -215,3 +215,3 @@ ![bignumber.js](https://raw.githubusercontent.com/MikeMcl/bignumber.js/gh-pages/bignumberjs.png) | ||
See the [README](https://github.com/MikeMcl/bignumber.js/perf/README.md) in the *perf* directory. | ||
See the [README](https://github.com/MikeMcl/bignumber.js/tree/master/perf) in the *perf* directory. | ||
@@ -247,8 +247,12 @@ ## Build | ||
See [LICENCE](https://github.com/MikeMcl/bignumber.js/LICENCE). | ||
See [LICENCE](https://github.com/MikeMcl/bignumber.js/blob/master/LICENCE). | ||
## Change Log | ||
####2.0.2 | ||
* 18/02/2015 | ||
* Correct links | ||
####2.0.1 | ||
* 17/02/2015 | ||
* 18/02/2015 | ||
* Add `max`, `min`, `precision`, `random`, `shift`, `toDigits` and `truncated` methods. | ||
@@ -255,0 +259,0 @@ * Add the short-forms: `add`, `mul`, `sd`, `sub` and `trunc`. |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
211586
314