Socket
Socket
Sign inDemoInstall

big.js

Package Overview
Dependencies
0
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0 to 2.2.0

30

big.js

@@ -1,2 +0,2 @@

/* big.js v2.1.0 https://github.com/MikeMcl/big.js/LICENCE */
/* big.js v2.2.0 https://github.com/MikeMcl/big.js/LICENCE */
;(function ( global ) {

@@ -6,3 +6,3 @@ 'use strict';

/*
big.js v2.1.0
big.js v2.2.0
A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.

@@ -31,4 +31,5 @@ https://github.com/MikeMcl/big.js/

* 2 Round to nearest neighbour. If equidistant, to even neighbour. (ROUND_HALF_EVEN)
* 3 Round away from zero. (ROUND_UP)
*/
Big['RM'] = 1; // 0, 1 or 2
Big['RM'] = 1; // 0, 1, 2 or 3

@@ -155,3 +156,3 @@ // The maximum value of 'Big.DP'.

* dp {number} Integer, 0 to MAX_DP inclusive.
* rm {number} 0, 1 or 2 ( ROUND_DOWN, ROUND_HALF_UP or ROUND_HALF_EVEN )
* rm {number} 0, 1, 2 or 3 ( ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP )
* [more] {boolean} Whether the result of division was truncated.

@@ -163,12 +164,15 @@ */

if ( rm !== 0 && rm !== 1 && rm !== 2 ) {
if ( rm === 1 ) {
// 'xc[i]' is the digit after the digit that may be rounded up.
more = xc[i] >= 5
} else if ( rm === 2 ) {
more = xc[i] > 5 || xc[i] == 5 && ( more || i < 0 || xc[i + 1] != null || xc[i - 1] & 1 )
} else if ( rm === 3 ) {
more = more || xc[i] != null || i < 0
} else if ( more = false, rm !== 0 ) {
throw '!Big.RM!'
}
// 'xc[i]' is the digit after the digit that may be rounded up.
rm = rm && ( xc[i] > 5 || xc[i] == 5 &&
( rm == 1 || more || i < 0 || xc[i + 1] != null || xc[i - 1] & 1 ) );
if ( i < 1 || !xc[0] ) {
x['c'] = rm
x['c'] = more
// 1, 0.1, 0.01, 0.001, 0.0001 etc.

@@ -184,3 +188,3 @@ ? ( x['e'] = -dp, [1] )

// Round up?
if ( rm ) {
if ( more ) {

@@ -526,3 +530,3 @@ // Rounding up may mean the previous digit has to be rounded up and so on.

// Remove leading zeros and adbust exponent accordingly.
// Remove leading zeros and adjust exponent accordingly.
for ( ; xc[0] == 0; xc.shift(), --ye ) {

@@ -683,3 +687,3 @@ }

* [dp] {number} Integer, 0 to MAX_DP inclusive.
* [rm] 0, 1 or 2 ( i.e. ROUND_DOWN, ROUND_HALF_UP or ROUND_HALF_EVEN )
* [rm] 0, 1, 2 or 3 ( ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP )
*/

@@ -686,0 +690,0 @@ P['round'] = function ( dp, rm ) {

@@ -1,1 +0,1 @@

/* big.js v2.1.0 https://github.com/MikeMcl/big.js/LICENCE */(function(n){"use strict";function t(n){var u,i,f,r=this;if(!(r instanceof t))return new t(n);if(n instanceof t){r.s=n.s,r.e=n.e,r.c=n.c.slice();return}if(n===0&&1/n<0)n="-0";else if(!l.test(n+=""))throw NaN;for(r.s=n.charAt(0)=="-"?(n=n.slice(1),-1):1,(u=n.indexOf("."))>-1&&(n=n.replace(".","")),(i=n.search(/e/i))>0?(u<0&&(u=i),u+=+n.slice(i+1),n=n.substring(0,i)):u<0&&(u=n.length),i=0;n.charAt(i)=="0";i++);if(i==(f=n.length))r.c=[r.e=0];else{for(;n.charAt(--f)=="0";);for(r.e=u-i-1,r.c=[],u=0;i<=f;r.c[u++]=+n.charAt(i++));}}function o(n,t,i,r){var u=n.c,f=n.e+t+1;if(i!==0&&i!==1&&i!==2)throw"!Big.RM!";if(i=i&&(u[f]>5||u[f]==5&&(i==1||r||f<0||u[f+1]!=null||u[f-1]&1)),f<1||!u[0])n.c=i?(n.e=-t,[1]):[n.e=0];else{if(u.length=f--,i)for(;++u[f]>9;)u[f]=0,f--||(++n.e,u.unshift(1));for(f=u.length;!u[--f];u.pop());}return n}function r(n,i){var s,e=n.c,o=(i=new t(i)).c,r=n.s,h=i.s,u=n.e,f=i.e;if(!e[0]||!o[0])return e[0]?r:o[0]?-h:0;if(r!=h)return r;if(s=r<0,u!=f)return u>f^s?1:-1;for(r=-1,h=(u=e.length)<(f=o.length)?u:f;++r<h;)if(e[r]!=o[r])return e[r]>o[r]^s?1:-1;return u==f?0:u>f^s?1:-1}function h(n,i,r){var u=i-(n=new t(n)).e,e=n.c;for(e.length>++i&&o(n,u,t.RM),u=e[0]?r?i:(e=n.c,n.e+u+1):u+1;e.length<u;e.push(0));return u=n.e,r==1||r==2&&(i<=u||u<=f)?(n.s<0&&e[0]?"-":"")+(e.length>1?(e.splice(1,0,"."),e.join("")):e[0])+(u<0?"e":"e+")+u:n.toString()}t.DP=20,t.RM=1;var u=1e6,c=1e6,f=-7,e=21,i=t.prototype,l=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,s=new t(1);i.abs=function(){var n=new t(this);return n.s=1,n},i.div=function(n){var w=this,c=w.c,e=(n=new t(n)).c,y=w.s==n.s?1:-1,l=t.DP;if(l!==~~l||l<0||l>u)throw"!Big.DP!";if(!c[0]||!e[0]){if(c[0]==e[0])throw NaN;if(!e[0])throw y/0;return new t(y*0)}var h,b,p,a,f,tt=e.slice(),k=h=e.length,it=c.length,i=c.slice(0,h),r=i.length,v=new t(s),d=v.c=[],g=0,nt=l+(v.e=w.e-n.e)+1;for(v.s=y,y=nt<0?0:nt,tt.unshift(0);r++<h;i.push(0));do{for(p=0;p<10;p++){if(h!=(r=i.length))a=h>r?1:-1;else for(f=-1,a=0;++f<h;)if(e[f]!=i[f]){a=e[f]>i[f]?1:-1;break}if(a<0){for(b=r==h?e:tt;r;){if(i[--r]<b[r]){for(f=r;f&&!i[--f];i[f]=9);--i[f],i[r]+=10}i[r]-=b[r]}for(;!i[0];i.shift());}else break}d[g++]=a?p:++p,i[0]&&a?i[r]=c[k]||0:i=[c[k]]}while((k++<it||i[0]!=null)&&y--);return d[0]||g==1||(d.shift(),v.e--),g>nt&&o(v,l,t.RM,i[0]!=null),v},i.eq=function(n){return!r(this,n)},i.gt=function(n){return r(this,n)>0},i.gte=function(n){return r(this,n)>-1},i.lt=function(n){return r(this,n)<0},i.lte=function(n){return r(this,n)<1},i.minus=function(n){var e,o,s,l,h=this,f=h.s,r=(n=new t(n)).s;if(f!=r)return n.s=-r,h.plus(n);var i=h.c.slice(),a=h.e,u=n.c,c=n.e;if(!i[0]||!u[0])return u[0]?(n.s=-r,n):new t(i[0]?h:0);if(f=a-c){for(e=(l=f<0)?(f=-f,i):(c=a,u),e.reverse(),r=f;r--;e.push(0));e.reverse()}else for(s=((l=i.length<u.length)?i:u).length,f=r=0;r<s;r++)if(i[r]!=u[r]){l=i[r]<u[r];break}if(l&&(e=i,i=u,u=e,n.s=-n.s),(r=-((s=i.length)-u.length))>0)for(;r--;i[s++]=0);for(r=u.length;r>f;){if(i[--r]<u[r]){for(o=r;o&&!i[--o];i[o]=9);--i[o],i[r]+=10}i[r]-=u[r]}for(;i[--s]==0;i.pop());for(;i[0]==0;i.shift(),--c);return i[0]||(i=[c=0]),n.c=i,n.e=c,n},i.mod=function(n){n=new t(n);var e,i=this,u=i.s,f=n.s;if(!n.c[0])throw NaN;return i.s=n.s=1,e=r(n,i)==1,i.s=u,n.s=f,e?new t(i):(u=t.DP,f=t.RM,t.DP=t.RM=0,i=i.div(n),t.DP=u,t.RM=f,this.minus(i.times(n)))},i.plus=function(n){var e,o=this,r=o.s,f=(n=new t(n)).s;if(r!=f)return n.s=-f,o.minus(n);var h=o.e,i=o.c,s=n.e,u=n.c;if(!i[0]||!u[0])return u[0]?n:new t(i[0]?o:r*0);if(i=i.slice(),r=h-s){for(e=r>0?(s=h,u):(r=-r,i),e.reverse();r--;e.push(0));e.reverse()}for(i.length-u.length<0&&(e=u,u=i,i=e),r=u.length,f=0;r;f=(i[--r]=i[r]+u[r]+f)/10^0,i[r]%=10);for(f&&(i.unshift(f),++s),r=i.length;i[--r]==0;i.pop());return n.c=i,n.e=s,n},i.pow=function(n){var u=n<0,i=new t(this),r=s;if(n!==~~n||n<-c||n>c)throw"!pow!";for(n=u?-n:n;;){if(n&1&&(r=r.times(i)),n>>=1,!n)break;i=i.times(i)}return u?s.div(r):r},i.round=function(n,i){var r=new t(this);if(n==null)n=0;else if(n!==~~n||n<0||n>u)throw"!round!";return o(r,n,i==null?t.RM:i),r},i.sqrt=function(){var u,n,f,r=this,s=r.c,i=r.s,e=r.e,h=new t("0.5");if(!s[0])return new t(r);if(i<0)throw NaN;i=Math.sqrt(r.toString()),i==0||i==1/0?(u=s.join(""),u.length+e&1||(u+="0"),n=new t(Math.sqrt(u).toString()),n.e=((e+1)/2|0)-(e<0||e&1)):n=new t(i.toString()),i=n.e+(t.DP+=4);do f=n,n=h.times(f.plus(r.div(f)));while(f.c.slice(0,i).join("")!==n.c.slice(0,i).join(""));return o(n,t.DP-=4,t.RM),n},i.times=function(n){var i,h=this,e=h.c,o=(n=new t(n)).c,s=e.length,r=o.length,f=h.e,u=n.e;if(n.s=h.s==n.s?1:-1,!e[0]||!o[0])return new t(n.s*0);for(n.e=f+u,s<r&&(i=e,e=o,o=i,u=s,s=r,r=u),u=s+r,i=[];u--;i.push(0));for(f=r-1;f>-1;f--){for(r=0,u=s+f;u>f;r=i[u]+o[f]*e[u-f-1]+r,i[u--]=r%10|0,r=r/10|0);r&&(i[u]=(i[u]+r)%10)}for(r&&++n.e,i[0]||i.shift(),u=i.length;!i[--u];i.pop());return n.c=i,n},i.toString=i.valueOf=function(){var r=this,t=r.e,n=r.c.join(""),i=n.length;if(t<=f||t>=e)n=n.charAt(0)+(i>1?"."+n.slice(1):"")+(t<0?"e":"e+")+t;else if(t<0){for(;++t;n="0"+n);n="0."+n}else if(t>0)if(++t>i)for(t-=i;t--;n+="0");else t<i&&(n=n.slice(0,t)+"."+n.slice(t));else i>1&&(n=n.charAt(0)+"."+n.slice(1));return r.s<0&&r.c[0]?"-"+n:n},i.toExponential=function(n){if(n==null)n=this.c.length-1;else if(n!==~~n||n<0||n>u)throw"!toExp!";return h(this,n,1)},i.toFixed=function(n){var t,i=this,r=f,o=e;if(f=-(e=1/0),n==null?t=i.toString():n===~~n&&n>=0&&n<=u&&(t=h(i,i.e+n),i.s<0&&i.c[0]&&t.indexOf("-")<0&&(t="-"+t)),f=r,e=o,!t)throw"!toFix!";return t},i.toPrecision=function(n){if(n==null)return this.toString();if(n!==~~n||n<1||n>u)throw"!toPre!";return h(this,n-1,2)},typeof module!="undefined"&&module.exports?module.exports=t:typeof define=="function"&&define.amd?define(function(){return t}):n.Big=t})(this)
/* big.js v2.2.0 https://github.com/MikeMcl/big.js/LICENCE */(function(n){"use strict";function t(n){var u,i,f,r=this;if(!(r instanceof t))return new t(n);if(n instanceof t){r.s=n.s;r.e=n.e;r.c=n.c.slice();return}if(n===0&&1/n<0)n="-0";else if(!l.test(n+=""))throw NaN;for(r.s=n.charAt(0)=="-"?(n=n.slice(1),-1):1,(u=n.indexOf("."))>-1&&(n=n.replace(".","")),(i=n.search(/e/i))>0?(u<0&&(u=i),u+=+n.slice(i+1),n=n.substring(0,i)):u<0&&(u=n.length),i=0;n.charAt(i)=="0";i++);if(i==(f=n.length))r.c=[r.e=0];else{for(;n.charAt(--f)=="0";);for(r.e=u-i-1,r.c=[],u=0;i<=f;r.c[u++]=+n.charAt(i++));}}function o(n,t,i,r){var f=n.c,u=n.e+t+1;if(i===1)r=f[u]>=5;else if(i===2)r=f[u]>5||f[u]==5&&(r||u<0||f[u+1]!=null||f[u-1]&1);else if(i===3)r=r||f[u]!=null||u<0;else if(r=!1,i!==0)throw"!Big.RM!";if(u<1||!f[0])n.c=r?(n.e=-t,[1]):[n.e=0];else{if(f.length=u--,r)for(;++f[u]>9;)f[u]=0,u--||(++n.e,f.unshift(1));for(u=f.length;!f[--u];f.pop());}return n}function r(n,i){var s,e=n.c,o=(i=new t(i)).c,r=n.s,h=i.s,u=n.e,f=i.e;if(!e[0]||!o[0])return e[0]?r:o[0]?-h:0;if(r!=h)return r;if(s=r<0,u!=f)return u>f^s?1:-1;for(r=-1,h=(u=e.length)<(f=o.length)?u:f;++r<h;)if(e[r]!=o[r])return e[r]>o[r]^s?1:-1;return u==f?0:u>f^s?1:-1}function h(n,i,r){var u=i-(n=new t(n)).e,e=n.c;for(e.length>++i&&o(n,u,t.RM),u=e[0]?r?i:(e=n.c,n.e+u+1):u+1;e.length<u;e.push(0));return u=n.e,r==1||r==2&&(i<=u||u<=f)?(n.s<0&&e[0]?"-":"")+(e.length>1?(e.splice(1,0,"."),e.join("")):e[0])+(u<0?"e":"e+")+u:n.toString()}t.DP=20;t.RM=1;var u=1e6,c=1e6,f=-7,e=21,i=t.prototype,l=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,s=new t(1);i.abs=function(){var n=new t(this);return n.s=1,n};i.div=function(n){var w=this,c=w.c,e=(n=new t(n)).c,y=w.s==n.s?1:-1,l=t.DP;if(l!==~~l||l<0||l>u)throw"!Big.DP!";if(!c[0]||!e[0]){if(c[0]==e[0])throw NaN;if(!e[0])throw y/0;return new t(y*0)}var h,b,p,a,f,tt=e.slice(),k=h=e.length,it=c.length,i=c.slice(0,h),r=i.length,v=new t(s),d=v.c=[],g=0,nt=l+(v.e=w.e-n.e)+1;for(v.s=y,y=nt<0?0:nt,tt.unshift(0);r++<h;i.push(0));do{for(p=0;p<10;p++){if(h!=(r=i.length))a=h>r?1:-1;else for(f=-1,a=0;++f<h;)if(e[f]!=i[f]){a=e[f]>i[f]?1:-1;break}if(a<0){for(b=r==h?e:tt;r;){if(i[--r]<b[r]){for(f=r;f&&!i[--f];i[f]=9);--i[f];i[r]+=10}i[r]-=b[r]}for(;!i[0];i.shift());}else break}d[g++]=a?p:++p;i[0]&&a?i[r]=c[k]||0:i=[c[k]]}while((k++<it||i[0]!=null)&&y--);return d[0]||g==1||(d.shift(),v.e--),g>nt&&o(v,l,t.RM,i[0]!=null),v};i.eq=function(n){return!r(this,n)};i.gt=function(n){return r(this,n)>0};i.gte=function(n){return r(this,n)>-1};i.lt=function(n){return r(this,n)<0};i.lte=function(n){return r(this,n)<1};i.minus=function(n){var e,o,s,l,h=this,f=h.s,r=(n=new t(n)).s;if(f!=r)return n.s=-r,h.plus(n);var i=h.c.slice(),a=h.e,u=n.c,c=n.e;if(!i[0]||!u[0])return u[0]?(n.s=-r,n):new t(i[0]?h:0);if(f=a-c){for(e=(l=f<0)?(f=-f,i):(c=a,u),e.reverse(),r=f;r--;e.push(0));e.reverse()}else for(s=((l=i.length<u.length)?i:u).length,f=r=0;r<s;r++)if(i[r]!=u[r]){l=i[r]<u[r];break}if(l&&(e=i,i=u,u=e,n.s=-n.s),(r=-((s=i.length)-u.length))>0)for(;r--;i[s++]=0);for(r=u.length;r>f;){if(i[--r]<u[r]){for(o=r;o&&!i[--o];i[o]=9);--i[o];i[r]+=10}i[r]-=u[r]}for(;i[--s]==0;i.pop());for(;i[0]==0;i.shift(),--c);return i[0]||(i=[c=0]),n.c=i,n.e=c,n};i.mod=function(n){n=new t(n);var e,i=this,u=i.s,f=n.s;if(!n.c[0])throw NaN;return i.s=n.s=1,e=r(n,i)==1,i.s=u,n.s=f,e?new t(i):(u=t.DP,f=t.RM,t.DP=t.RM=0,i=i.div(n),t.DP=u,t.RM=f,this.minus(i.times(n)))};i.plus=function(n){var e,o=this,r=o.s,f=(n=new t(n)).s;if(r!=f)return n.s=-f,o.minus(n);var h=o.e,i=o.c,s=n.e,u=n.c;if(!i[0]||!u[0])return u[0]?n:new t(i[0]?o:r*0);if(i=i.slice(),r=h-s){for(e=r>0?(s=h,u):(r=-r,i),e.reverse();r--;e.push(0));e.reverse()}for(i.length-u.length<0&&(e=u,u=i,i=e),r=u.length,f=0;r;f=(i[--r]=i[r]+u[r]+f)/10^0,i[r]%=10);for(f&&(i.unshift(f),++s),r=i.length;i[--r]==0;i.pop());return n.c=i,n.e=s,n};i.pow=function(n){var u=n<0,i=new t(this),r=s;if(n!==~~n||n<-c||n>c)throw"!pow!";for(n=u?-n:n;;){if(n&1&&(r=r.times(i)),n>>=1,!n)break;i=i.times(i)}return u?s.div(r):r};i.round=function(n,i){var r=new t(this);if(n==null)n=0;else if(n!==~~n||n<0||n>u)throw"!round!";return o(r,n,i==null?t.RM:i),r};i.sqrt=function(){var u,n,f,r=this,s=r.c,i=r.s,e=r.e,h=new t("0.5");if(!s[0])return new t(r);if(i<0)throw NaN;i=Math.sqrt(r.toString());i==0||i==1/0?(u=s.join(""),u.length+e&1||(u+="0"),n=new t(Math.sqrt(u).toString()),n.e=((e+1)/2|0)-(e<0||e&1)):n=new t(i.toString());i=n.e+(t.DP+=4);do f=n,n=h.times(f.plus(r.div(f)));while(f.c.slice(0,i).join("")!==n.c.slice(0,i).join(""));return o(n,t.DP-=4,t.RM),n};i.times=function(n){var i,h=this,e=h.c,o=(n=new t(n)).c,s=e.length,r=o.length,f=h.e,u=n.e;if(n.s=h.s==n.s?1:-1,!e[0]||!o[0])return new t(n.s*0);for(n.e=f+u,s<r&&(i=e,e=o,o=i,u=s,s=r,r=u),u=s+r,i=[];u--;i.push(0));for(f=r-1;f>-1;f--){for(r=0,u=s+f;u>f;r=i[u]+o[f]*e[u-f-1]+r,i[u--]=r%10|0,r=r/10|0);r&&(i[u]=(i[u]+r)%10)}for(r&&++n.e,i[0]||i.shift(),u=i.length;!i[--u];i.pop());return n.c=i,n};i.toString=i.valueOf=function(){var r=this,t=r.e,n=r.c.join(""),i=n.length;if(t<=f||t>=e)n=n.charAt(0)+(i>1?"."+n.slice(1):"")+(t<0?"e":"e+")+t;else if(t<0){for(;++t;n="0"+n);n="0."+n}else if(t>0)if(++t>i)for(t-=i;t--;n+="0");else t<i&&(n=n.slice(0,t)+"."+n.slice(t));else i>1&&(n=n.charAt(0)+"."+n.slice(1));return r.s<0&&r.c[0]?"-"+n:n};i.toExponential=function(n){if(n==null)n=this.c.length-1;else if(n!==~~n||n<0||n>u)throw"!toExp!";return h(this,n,1)};i.toFixed=function(n){var t,i=this,r=f,o=e;if(f=-(e=1/0),n==null?t=i.toString():n===~~n&&n>=0&&n<=u&&(t=h(i,i.e+n),i.s<0&&i.c[0]&&t.indexOf("-")<0&&(t="-"+t)),f=r,e=o,!t)throw"!toFix!";return t};i.toPrecision=function(n){if(n==null)return this.toString();if(n!==~~n||n<1||n>u)throw"!toPre!";return h(this,n-1,2)};typeof module!="undefined"&&module.exports?module.exports=t:typeof define=="function"&&define.amd?define(function(){return t}):n.Big=t})(this)
{
"name": "big.js",
"description": "A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic",
"version": "2.1.0",
"version": "2.2.0",
"keywords": [

@@ -6,0 +6,0 @@ "arbitrary",

@@ -13,3 +13,3 @@

allMs = [].concat.apply([], Ms),
bdRounding = [1, 4, 6],
bdRounding = [1, 4, 6, 0],
bdTotal = 0,

@@ -175,3 +175,3 @@ bnTotal = 0,

if (bdM == 'divide') {
rounding = Math.floor(Math.random() * 3);
rounding = Math.floor(Math.random() * 4);
console.log(

@@ -178,0 +178,0 @@ '\n Decimal places: %d\n Rounding mode: %d',

# big.js #
A small, fast Javascript library for arbitrary-precision decimal arithmetic.
A small, fast JavaScript library for arbitrary-precision decimal arithmetic.

@@ -10,6 +10,6 @@ The little sister to [bignumber.js](https://github.com/MikeMcl/bignumber.js/).

- Faster, smaller and easier-to-use than Javascript versions of Java's BigDecimal
- Only 2.5 KB minified and gzipped
- Faster, smaller and easier-to-use than JavaScript versions of Java's BigDecimal
- Only 2.6 KB minified and gzipped
- Simple API
- Replicates the `toExponential`, `toFixed` and `toPrecision` methods of Javascript's Number type
- Replicates the `toExponential`, `toFixed` and `toPrecision` methods of JavaScript's Number type
- Includes a `sqrt` method

@@ -22,3 +22,3 @@ - Stores values in an accessible decimal floating point format

The library is the single Javascript file *big.js* (or *big.min.js*, which is *big.js* minified).
The library is the single JavaScript file *big.js* (or *big.min.js*, which is *big.js* minified).

@@ -68,3 +68,3 @@ It can be loaded via a script tag in an HTML document for the browser

Like Javascript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods.
Like JavaScript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods.

@@ -106,3 +106,3 @@ x = new Big(255.5)

To test a single method, from a command-line shell at the *test/* directory, use e.g.
To test a single method, from a command-line shell at the *test* directory, use e.g.

@@ -115,5 +115,5 @@ $ node toFixed

For the browser, see *single-test.html* and *every-test.html* in the *test/browser/* directory.
For the browser, see *single-test.html* and *every-test.html* in the *test/browser* directory.
*big-vs-number.html* enables some of the methods of big.js to be compared with those of Javascript's Number type.
*big-vs-number.html* enables some of the methods of big.js to be compared with those of JavaScript's Number type.

@@ -124,3 +124,3 @@ ## Performance

*big-vs-bigdecimal.html* tests the performance of big.js against the Javascript translations of two versions of BigDecimal, its use should be more or less self-explanatory.
*big-vs-bigdecimal.html* tests the performance of big.js against the JavaScript translations of two versions of BigDecimal, its use should be more or less self-explanatory.
(The GWT version doesn't work in IE 6.)

@@ -158,3 +158,3 @@

The *big.min.js* already present was created with *Microsoft Ajax Minifier 4.91*, as it produced a smaller file size.
The *big.min.js* already present was created with *Microsoft Ajax Minifier 4.95*, as it produced a smaller file size.

@@ -181,2 +181,6 @@ ## Feedback

####2.2.0
* 11/07/13 Added 'round up' mode.
####2.1.0

@@ -183,0 +187,0 @@

@@ -774,2 +774,13 @@

// ROUND_UP
Big.DP = 0;
Big.RM = 3;
T('11', '101');
T('11', '111');
T('1000', 999000.25);
T('1', 0.25);
T('1', 0.001);
Big.DP = 2;
T('0.04', 0.001);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');

@@ -776,0 +787,0 @@ return [passed, total];;

@@ -434,2 +434,37 @@ var count = (function toExponential(Big) {

// ROUND_UP
Big.RM = 3;
T('-2.033619450856645241153977e+0', '-2.03361945085664524115397653636144859', 24);
T('1.130e+8', '112955590.0430616', 3);
T('1.13e+8', '112155590.0430616', 2);
T('-2.1366468193419876852426155614364269e+10', '-21366468193.419876852426155614364269', 34);
T('5.82086615659566151521e+7', '58208661.56595661515205734890860077163', 20);
T('9.1615809372817426111209e+6', '9161580.937281742611120838868847823478250167882379624', 22);
T('3.8976506901061164197e+1', '38.97650690106116419699490320634490920742414', 19);
T('9.0994914931570087194607344641722310104e+6', '9099491.4931570087194607344641722310103895224905', 37);
T('6.06e+5', '605633', 2);
T('6.06e+5', '605133', 2);
T('2.6999974790473705518992118e+1', '26.9999747904737055189921170044987', 25);
T('6.7108801361722e+6', '6710880.136172156342982663450743452', 13);
T('-8.0e+0', '-8', 1);
T('3.000e-2', '0.03', 3);
T('-4.7e+2', '-469', 1);
T('-4.6e+2', '-460', 1);
T('-4.7e+2', '-464', 1);
T('-6.3000e+0', '-6.3', 4);
T('-5.5e+2', '-542', 1);
T('-5.2000e+0', '-5.2', 4);
T('-9.00000e-2', '-0.09', 5);
T('-3.1000e-1', '-0.31', 4);
T('-4.4e+2', '-436', 1);
T('-3.00e+0', '-3', 2);
T('-5.00e-2', '-0.05', 2);
T('1.00e-2', '0.01', 2);
T('1.23e+2', '12.3e1', null);
T('1.23e+2', '12.3e1', undefined);
T('2e+2', '12.3e1', 0);
T('-2e+2', '-12.3e1', 0);
T('2e+2', '12.3e1', -0);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');

@@ -436,0 +471,0 @@ return [passed, total];;

@@ -449,2 +449,58 @@ var count = (function toPrecision(Big) {

// ROUND_UP
Big.RM = 3;
T('7.905300379788e+16', '79053003797878062.6454954', 13);
T('-6.83490000000e-13', '-0.00000000000068349', 12);
T('-62760641815.69084973661201202', '-62760641815.690849736612012010742308663', 28);
T('0.000705', '0.000704496313', 3);
T('82926865286287.8852357368342860830310721063079299644', '82926865286287.88523573683428608303107210630792996432', 51);
T('-0.00032388272393900301214220090249', '-0.00032388272393900301214220090248744799603424908', 29);
T('8.7e+12', '8621641486938.4837308885005093571508566552428700982454', 2);
T('2', '2', 1);
T('1.4641440117052559075e+20', '146414401170525590746.047955203899370771105088', 20);
T('3511.925583', '3511.925583', 10);
T('2861824.253079699095728', '2861824.253079699095727765750377038689', 22);
T('-3.940097757e+10', '-39400977564.548924098664431671700066962', 10);
T('-888', '-888', 3);
T('-0.000302106125213724988141721256105', '-0.00030210612521372498814172125610432438685', 30);
T('6943.4804552555315615809650428503', '6943.480455255531561580965042850266831249032130818358478956', 32);
T('3365679', '3365678.3397481381125085749', 7);
T('-5.3943374314e+19', '-53943374313769567458.386865325', 11);
T('-6.67880509225510150542252852147049489938254298497980', '-6.6788050922551015054225285214704948993825429849797925563674', 51);
T('1.36425e+18', '1364240644139816224.60228356028', 6);
T('1.410236477950416726e+23', '141023647795041672538410.84935693266374259666015274447', 19);
T('-802.817766', '-802.81776500697712984253334522', 9);
T('-5.276210722424690668896260075355037218851', '-5.27621072242469066889626007535503721885096', 40);
T('-0.000874209568970788', '-0.0008742095689707877849902027926289294748756775668387', 15);
T('0.092053833162002', '0.09205383316200189249855864903410820435666385119723209239', 14);
T('7.0656298318128210e-14', '0.0000000000000706562983181282092835675843980510112', 17);
T('-8.66511516852116659e+18', '-8665115168521166587', 18);
T('3.3490648464e+22', '33490648463534229842937.79268276945692333064632966129475', 11);
T('-39041587174692569176.82740706154183895', '-39041587174692569176.827407061541838942655371389185', 37);
T('-3834.0', '-3834', 5);
T('-0.008912382644814418776268630', '-0.00891238264481441877626863', 25);
T('-2.1e+5', '-206119', 2);
T('4.83340000000e-8', '0.000000048334', 12);
T('3.185196533675230520000000000000e-19', '0.000000000000000000318519653367523052', 31);
T('6.0431217298488095562718496137220939447806000000000000000e-17', '0.000000000000000060431217298488095562718496137220939447806', 56);
T('196.519569070149035', '196.51956907014903416531531', 18);
T('0.0000046405006597117307566000', '0.0000046405006597117307566', 23);
T('9.10e+16', '90974867783311624.1073050261392195984211985571898902', 3);
T('0.0009', '0.0009', 1);
T('-784.345', '-784.3442317667756502522526185951859933319162', 6);
T('4.407336482399797058693e+28', '44073364823997970586929155979.43263841350505', 22);
T('-3.0000000000e-13', '-0.0000000000003', 11);
T('0.800', '0.8', 3);
T('0.04643398170143261158595951942032', '0.046433981701432611585959519420314960367263', 31);
T('-8e+26', '-786589693451258754942279859.3834', 1);
T('-26.0', '-26', 3);
T('-8.462226728e+11', '-846222672789.2087639320702375427266333530942524245', 10);
T('-5e-7', '-0.0000004019666978288041783154210868', 1);
T('-315609.775843992', '-315609.775843992', 15);
T('-3.319e+9', '-3318880945', 4);
T('-7', '-6.2847', 1);
T('7.754663772706e+20', '775466377270546647581.033426922028458904663', 13);
T('-7.2577466365074249372160551716564e+25', '-72577466365074249372160551.71656300408', 32);
log('\n ' + passed + ' of ' + total + ' tests passed in ' + (+new Date() - start) + ' ms \n');

@@ -451,0 +507,0 @@ return [passed, total];;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc