Socket
Socket
Sign inDemoInstall

big.js

Package Overview
Dependencies
42
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.1.2 to 5.2.1

30

big.js
/*
* big.js v5.1.2
* big.js v5.2.1
* A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.
* Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>
* Copyright (c) 2018 Michael Mclaughlin <M8ch88l@gmail.com>
* https://github.com/MikeMcl/big.js/LICENCE

@@ -110,3 +110,3 @@ */

Big.PE = PE;
Big.version = '5.0.2';
Big.version = '5.2.1';

@@ -195,3 +195,3 @@ return Big;

} else if (rm === 3) {
more = more || xc[i] !== UNDEFINED || i < 0;
more = more || !!xc[0];
} else {

@@ -663,3 +663,3 @@ more = false;

// Prepend zeros to equalise exponents.
// Note: Faster to use reverse then do unshifts.
// Note: reverse faster than unshifts.
if (a = xe - ye) {

@@ -736,8 +736,9 @@ if (a > 0) {

/*
* Return a new Big whose value is the value of this Big rounded to a maximum of dp decimal
* places using rounding mode rm.
* Return a new Big whose value is the value of this Big rounded using rounding mode rm
* to a maximum of dp decimal places, or, if dp is negative, to an integer which is a
* multiple of 10**-dp.
* If dp is not specified, round to 0 decimal places.
* If rm is not specified, use Big.RM.
*
* dp? {number} Integer, 0 to MAX_DP inclusive.
* dp? {number} Integer, -MAX_DP to MAX_DP inclusive.
* rm? 0, 1, 2 or 3 (ROUND_DOWN, ROUND_HALF_UP, ROUND_HALF_EVEN, ROUND_UP)

@@ -748,3 +749,3 @@ */

if (dp === UNDEFINED) dp = 0;
else if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
else if (dp !== ~~dp || dp < -MAX_DP || dp > MAX_DP) throw Error(INVALID_DP);
return round(new Big(this), dp, rm === UNDEFINED ? Big.RM : rm);

@@ -773,13 +774,14 @@ };

// Estimate.
s = Math.sqrt(x.toString());
s = Math.sqrt(x + '');
// Math.sqrt underflow/overflow?
// Re-estimate: pass x to Math.sqrt as integer, then adjust the result exponent.
// Re-estimate: pass x coefficient to Math.sqrt as integer, then adjust the result exponent.
if (s === 0 || s === 1 / 0) {
c = x.c.join('');
if (!(c.length + e & 1)) c += '0';
r = new Big(Math.sqrt(c).toString());
r.e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
s = Math.sqrt(c);
e = ((e + 1) / 2 | 0) - (e < 0 || e & 1);
r = new Big((s == 1 / 0 ? '1e' : (s = s.toExponential()).slice(0, s.indexOf('e') + 1)) + e);
} else {
r = new Big(s.toString());
r = new Big(s);
}

@@ -786,0 +788,0 @@

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

/* big.js v5.1.2 https://github.com/MikeMcl/big.js/LICENCE */
!function(e){"use strict";function r(){function e(n){var i=this;return i instanceof e?(n instanceof e?(i.s=n.s,i.e=n.e,i.c=n.c.slice()):t(i,n),void(i.constructor=e)):n===m?r():new e(n)}return e.prototype=v,e.DP=s,e.RM=f,e.NE=h,e.PE=l,e.version="5.0.2",e}function t(e,r){var t,n,i;if(0===r&&0>1/r)r="-0";else if(!E.test(r+=""))throw Error(g+"number");for(e.s="-"==r.charAt(0)?(r=r.slice(1),-1):1,(t=r.indexOf("."))>-1&&(r=r.replace(".","")),(n=r.search(/e/i))>0?(0>t&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):0>t&&(t=r.length),i=r.length,n=0;i>n&&"0"==r.charAt(n);)++n;if(n==i)e.c=[e.e=0];else{for(;i>0&&"0"==r.charAt(--i););for(e.e=t-n-1,e.c=[],t=0;i>=n;)e.c[t++]=+r.charAt(n++)}return e}function n(e,r,t,n){var i=e.c,o=e.e+r+1;if(o<i.length){if(1===t)n=i[o]>=5;else if(2===t)n=i[o]>5||5==i[o]&&(n||0>o||i[o+1]!==m||1&i[o-1]);else if(3===t)n=n||i[o]!==m||0>o;else if(n=!1,0!==t)throw Error(w);if(1>o)i.length=1,n?(e.e=-r,i[0]=1):i[0]=e.e=0;else{if(i.length=o--,n)for(;++i[o]>9;)i[o]=0,o--||(++e.e,i.unshift(1));for(o=i.length;!i[--o];)i.pop()}}else if(0>t||t>3||t!==~~t)throw Error(w);return e}function i(e,r,t,i){var o,s,f=e.constructor,u=!e.c[0];if(t!==m){if(t!==~~t||(3==r)>t||t>c)throw Error(3==r?g+"precision":p);for(e=new f(e),t=i-e.e,e.c.length>++i&&n(e,t,f.RM),2==r&&(i=e.e+t+1);e.c.length<i;)e.c.push(0)}if(o=e.e,s=e.c.join(""),t=s.length,2!=r&&(1==r||3==r&&o>=i||o<=f.NE||o>=f.PE))s=s.charAt(0)+(t>1?"."+s.slice(1):"")+(0>o?"e":"e+")+o;else if(0>o){for(;++o;)s="0"+s;s="0."+s}else if(o>0)if(++o>t)for(o-=t;o--;)s+="0";else t>o&&(s=s.slice(0,o)+"."+s.slice(o));else t>1&&(s=s.charAt(0)+"."+s.slice(1));return e.s<0&&(!u||4==r)?"-"+s:s}var o,s=20,f=1,c=1e6,u=1e6,h=-7,l=21,a="[big.js] ",g=a+"Invalid ",p=g+"decimal places",w=g+"rounding mode",d=a+"Division by zero",v={},m=void 0,E=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;v.abs=function(){var e=new this.constructor(this);return e.s=1,e},v.cmp=function(e){var r,t=this,n=t.c,i=(e=new t.constructor(e)).c,o=t.s,s=e.s,f=t.e,c=e.e;if(!n[0]||!i[0])return n[0]?o:i[0]?-s:0;if(o!=s)return o;if(r=0>o,f!=c)return f>c^r?1:-1;for(s=(f=n.length)<(c=i.length)?f:c,o=-1;++o<s;)if(n[o]!=i[o])return n[o]>i[o]^r?1:-1;return f==c?0:f>c^r?1:-1},v.div=function(e){var r=this,t=r.constructor,i=r.c,o=(e=new t(e)).c,s=r.s==e.s?1:-1,f=t.DP;if(f!==~~f||0>f||f>c)throw Error(p);if(!o[0])throw Error(d);if(!i[0])return new t(0*s);var u,h,l,a,g,w=o.slice(),v=u=o.length,E=i.length,M=i.slice(0,u),P=M.length,b=e,D=b.c=[],R=0,A=f+(b.e=r.e-e.e)+1;for(b.s=s,s=0>A?0:A,w.unshift(0);P++<u;)M.push(0);do{for(l=0;10>l;l++){if(u!=(P=M.length))a=u>P?1:-1;else for(g=-1,a=0;++g<u;)if(o[g]!=M[g]){a=o[g]>M[g]?1:-1;break}if(!(0>a))break;for(h=P==u?o:w;P;){if(M[--P]<h[P]){for(g=P;g&&!M[--g];)M[g]=9;--M[g],M[P]+=10}M[P]-=h[P]}for(;!M[0];)M.shift()}D[R++]=a?l:++l,M[0]&&a?M[P]=i[v]||0:M=[i[v]]}while((v++<E||M[0]!==m)&&s--);return D[0]||1==R||(D.shift(),b.e--),R>A&&n(b,f,t.RM,M[0]!==m),b},v.eq=function(e){return!this.cmp(e)},v.gt=function(e){return this.cmp(e)>0},v.gte=function(e){return this.cmp(e)>-1},v.lt=function(e){return this.cmp(e)<0},v.lte=function(e){return this.cmp(e)<1},v.minus=v.sub=function(e){var r,t,n,i,o=this,s=o.constructor,f=o.s,c=(e=new s(e)).s;if(f!=c)return e.s=-c,o.plus(e);var u=o.c.slice(),h=o.e,l=e.c,a=e.e;if(!u[0]||!l[0])return l[0]?(e.s=-c,e):new s(u[0]?o:0);if(f=h-a){for((i=0>f)?(f=-f,n=u):(a=h,n=l),n.reverse(),c=f;c--;)n.push(0);n.reverse()}else for(t=((i=u.length<l.length)?u:l).length,f=c=0;t>c;c++)if(u[c]!=l[c]){i=u[c]<l[c];break}if(i&&(n=u,u=l,l=n,e.s=-e.s),(c=(t=l.length)-(r=u.length))>0)for(;c--;)u[r++]=0;for(c=r;t>f;){if(u[--t]<l[t]){for(r=t;r&&!u[--r];)u[r]=9;--u[r],u[t]+=10}u[t]-=l[t]}for(;0===u[--c];)u.pop();for(;0===u[0];)u.shift(),--a;return u[0]||(e.s=1,u=[a=0]),e.c=u,e.e=a,e},v.mod=function(e){var r,t=this,n=t.constructor,i=t.s,o=(e=new n(e)).s;if(!e.c[0])throw Error(d);return t.s=e.s=1,r=1==e.cmp(t),t.s=i,e.s=o,r?new n(t):(i=n.DP,o=n.RM,n.DP=n.RM=0,t=t.div(e),n.DP=i,n.RM=o,this.minus(t.times(e)))},v.plus=v.add=function(e){var r,t=this,n=t.constructor,i=t.s,o=(e=new n(e)).s;if(i!=o)return e.s=-o,t.minus(e);var s=t.e,f=t.c,c=e.e,u=e.c;if(!f[0]||!u[0])return u[0]?e:new n(f[0]?t:0*i);if(f=f.slice(),i=s-c){for(i>0?(c=s,r=u):(i=-i,r=f),r.reverse();i--;)r.push(0);r.reverse()}for(f.length-u.length<0&&(r=u,u=f,f=r),i=u.length,o=0;i;f[i]%=10)o=(f[--i]=f[i]+u[i]+o)/10|0;for(o&&(f.unshift(o),++c),i=f.length;0===f[--i];)f.pop();return e.c=f,e.e=c,e},v.pow=function(e){var r=this,t=new r.constructor(1),n=t,i=0>e;if(e!==~~e||-u>e||e>u)throw Error(g+"exponent");for(i&&(e=-e);1&e&&(n=n.times(r)),e>>=1,e;)r=r.times(r);return i?t.div(n):n},v.round=function(e,r){var t=this.constructor;if(e===m)e=0;else if(e!==~~e||0>e||e>c)throw Error(p);return n(new t(this),e,r===m?t.RM:r)},v.sqrt=function(){var e,r,t,i=this,o=i.constructor,s=i.s,f=i.e,c=new o(.5);if(!i.c[0])return new o(i);if(0>s)throw Error(a+"No square root");s=Math.sqrt(i.toString()),0===s||s===1/0?(r=i.c.join(""),r.length+f&1||(r+="0"),e=new o(Math.sqrt(r).toString()),e.e=((f+1)/2|0)-(0>f||1&f)):e=new o(s.toString()),f=e.e+(o.DP+=4);do t=e,e=c.times(t.plus(i.div(t)));while(t.c.slice(0,f).join("")!==e.c.slice(0,f).join(""));return n(e,o.DP-=4,o.RM)},v.times=v.mul=function(e){var r,t=this,n=t.constructor,i=t.c,o=(e=new n(e)).c,s=i.length,f=o.length,c=t.e,u=e.e;if(e.s=t.s==e.s?1:-1,!i[0]||!o[0])return new n(0*e.s);for(e.e=c+u,f>s&&(r=i,i=o,o=r,u=s,s=f,f=u),r=new Array(u=s+f);u--;)r[u]=0;for(c=f;c--;){for(f=0,u=s+c;u>c;)f=r[u]+o[c]*i[u-c-1]+f,r[u--]=f%10,f=f/10|0;r[u]=(r[u]+f)%10}for(f?++e.e:r.shift(),c=r.length;!r[--c];)r.pop();return e.c=r,e},v.toExponential=function(e){return i(this,1,e,e)},v.toFixed=function(e){return i(this,2,e,this.e+e)},v.toPrecision=function(e){return i(this,3,e,e-1)},v.toString=function(){return i(this)},v.valueOf=v.toJSON=function(){return i(this,4)},o=r(),o["default"]=o.Big=o,"function"==typeof define&&define.amd?define(function(){return o}):"undefined"!=typeof module&&module.exports?module.exports=o:e.Big=o}(this);
//# sourceMappingURL=doc/big.js.map
/* big.js v5.2.1 https://github.com/MikeMcl/big.js/LICENCE */
!function(e){"use strict";var r,i=20,s=1,P=1e6,o=-7,f=21,c="[big.js] ",u=c+"Invalid ",b=u+"decimal places",h=u+"rounding mode",x=c+"Division by zero",l={},D=void 0,a=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function R(e,r,t,n){var i=e.c,s=e.e+r+1;if(s<i.length){if(1===t)n=5<=i[s];else if(2===t)n=5<i[s]||5==i[s]&&(n||s<0||i[s+1]!==D||1&i[s-1]);else if(3===t)n=n||!!i[0];else if(n=!1,0!==t)throw Error(h);if(s<1)i.length=1,i[0]=n?(e.e=-r,1):e.e=0;else{if(i.length=s--,n)for(;9<++i[s];)i[s]=0,s--||(++e.e,i.unshift(1));for(s=i.length;!i[--s];)i.pop()}}else if(t<0||3<t||t!==~~t)throw Error(h);return e}function t(e,r,t,n){var i,s,o=e.constructor,f=!e.c[0];if(t!==D){if(t!==~~t||t<(3==r)||P<t)throw Error(3==r?u+"precision":b);for(t=n-(e=new o(e)).e,e.c.length>++n&&R(e,t,o.RM),2==r&&(n=e.e+t+1);e.c.length<n;)e.c.push(0)}if(i=e.e,t=(s=e.c.join("")).length,2!=r&&(1==r||3==r&&n<=i||i<=o.NE||i>=o.PE))s=s.charAt(0)+(1<t?"."+s.slice(1):"")+(i<0?"e":"e+")+i;else if(i<0){for(;++i;)s="0"+s;s="0."+s}else if(0<i)if(++i>t)for(i-=t;i--;)s+="0";else i<t&&(s=s.slice(0,i)+"."+s.slice(i));else 1<t&&(s=s.charAt(0)+"."+s.slice(1));return e.s<0&&(!f||4==r)?"-"+s:s}l.abs=function(){var e=new this.constructor(this);return e.s=1,e},l.cmp=function(e){var r,t=this,n=t.c,i=(e=new t.constructor(e)).c,s=t.s,o=e.s,f=t.e,c=e.e;if(!n[0]||!i[0])return n[0]?s:i[0]?-o:0;if(s!=o)return s;if(r=s<0,f!=c)return c<f^r?1:-1;for(o=(f=n.length)<(c=i.length)?f:c,s=-1;++s<o;)if(n[s]!=i[s])return n[s]>i[s]^r?1:-1;return f==c?0:c<f^r?1:-1},l.div=function(e){var r=this,t=r.constructor,n=r.c,i=(e=new t(e)).c,s=r.s==e.s?1:-1,o=t.DP;if(o!==~~o||o<0||P<o)throw Error(b);if(!i[0])throw Error(x);if(!n[0])return new t(0*s);var f,c,u,h,l,a=i.slice(),g=f=i.length,p=n.length,w=n.slice(0,f),d=w.length,v=e,m=v.c=[],E=0,M=o+(v.e=r.e-e.e)+1;for(v.s=s,s=M<0?0:M,a.unshift(0);d++<f;)w.push(0);do{for(u=0;u<10;u++){if(f!=(d=w.length))h=d<f?1:-1;else for(l=-1,h=0;++l<f;)if(i[l]!=w[l]){h=i[l]>w[l]?1:-1;break}if(!(h<0))break;for(c=d==f?i:a;d;){if(w[--d]<c[d]){for(l=d;l&&!w[--l];)w[l]=9;--w[l],w[d]+=10}w[d]-=c[d]}for(;!w[0];)w.shift()}m[E++]=h?u:++u,w[0]&&h?w[d]=n[g]||0:w=[n[g]]}while((g++<p||w[0]!==D)&&s--);return m[0]||1==E||(m.shift(),v.e--),M<E&&R(v,o,t.RM,w[0]!==D),v},l.eq=function(e){return!this.cmp(e)},l.gt=function(e){return 0<this.cmp(e)},l.gte=function(e){return-1<this.cmp(e)},l.lt=function(e){return this.cmp(e)<0},l.lte=function(e){return this.cmp(e)<1},l.minus=l.sub=function(e){var r,t,n,i,s=this,o=s.constructor,f=s.s,c=(e=new o(e)).s;if(f!=c)return e.s=-c,s.plus(e);var u=s.c.slice(),h=s.e,l=e.c,a=e.e;if(!u[0]||!l[0])return l[0]?(e.s=-c,e):new o(u[0]?s:0);if(f=h-a){for((n=(i=f<0)?(f=-f,u):(a=h,l)).reverse(),c=f;c--;)n.push(0);n.reverse()}else for(t=((i=u.length<l.length)?u:l).length,f=c=0;c<t;c++)if(u[c]!=l[c]){i=u[c]<l[c];break}if(i&&(n=u,u=l,l=n,e.s=-e.s),0<(c=(t=l.length)-(r=u.length)))for(;c--;)u[r++]=0;for(c=r;f<t;){if(u[--t]<l[t]){for(r=t;r&&!u[--r];)u[r]=9;--u[r],u[t]+=10}u[t]-=l[t]}for(;0===u[--c];)u.pop();for(;0===u[0];)u.shift(),--a;return u[0]||(e.s=1,u=[a=0]),e.c=u,e.e=a,e},l.mod=function(e){var r,t=this,n=t.constructor,i=t.s,s=(e=new n(e)).s;if(!e.c[0])throw Error(x);return t.s=e.s=1,r=1==e.cmp(t),t.s=i,e.s=s,r?new n(t):(i=n.DP,s=n.RM,n.DP=n.RM=0,t=t.div(e),n.DP=i,n.RM=s,this.minus(t.times(e)))},l.plus=l.add=function(e){var r,t=this,n=t.constructor,i=t.s,s=(e=new n(e)).s;if(i!=s)return e.s=-s,t.minus(e);var o=t.e,f=t.c,c=e.e,u=e.c;if(!f[0]||!u[0])return u[0]?e:new n(f[0]?t:0*i);if(f=f.slice(),i=o-c){for((r=0<i?(c=o,u):(i=-i,f)).reverse();i--;)r.push(0);r.reverse()}for(f.length-u.length<0&&(r=u,u=f,f=r),i=u.length,s=0;i;f[i]%=10)s=(f[--i]=f[i]+u[i]+s)/10|0;for(s&&(f.unshift(s),++c),i=f.length;0===f[--i];)f.pop();return e.c=f,e.e=c,e},l.pow=function(e){var r=this,t=new r.constructor(1),n=t,i=e<0;if(e!==~~e||e<-1e6||1e6<e)throw Error(u+"exponent");for(i&&(e=-e);1&e&&(n=n.times(r)),e>>=1;)r=r.times(r);return i?t.div(n):n},l.round=function(e,r){var t=this.constructor;if(e===D)e=0;else if(e!==~~e||e<-P||P<e)throw Error(b);return R(new t(this),e,r===D?t.RM:r)},l.sqrt=function(){var e,r,t,n=this,i=n.constructor,s=n.s,o=n.e,f=new i(.5);if(!n.c[0])return new i(n);if(s<0)throw Error(c+"No square root");for(o=(e=0===(s=Math.sqrt(n+""))||s===1/0?((r=n.c.join("")).length+o&1||(r+="0"),o=((o+1)/2|0)-(o<0||1&o),new i(((s=Math.sqrt(r))==1/0?"1e":(s=s.toExponential()).slice(0,s.indexOf("e")+1))+o)):new i(s)).e+(i.DP+=4);t=e,e=f.times(t.plus(n.div(t))),t.c.slice(0,o).join("")!==e.c.slice(0,o).join(""););return R(e,i.DP-=4,i.RM)},l.times=l.mul=function(e){var r,t=this.constructor,n=this.c,i=(e=new t(e)).c,s=n.length,o=i.length,f=this.e,c=e.e;if(e.s=this.s==e.s?1:-1,!n[0]||!i[0])return new t(0*e.s);for(e.e=f+c,s<o&&(r=n,n=i,i=r,c=s,s=o,o=c),r=new Array(c=s+o);c--;)r[c]=0;for(f=o;f--;){for(o=0,c=s+f;f<c;)o=r[c]+i[f]*n[c-f-1]+o,r[c--]=o%10,o=o/10|0;r[c]=(r[c]+o)%10}for(o?++e.e:r.shift(),f=r.length;!r[--f];)r.pop();return e.c=r,e},l.toExponential=function(e){return t(this,1,e,e)},l.toFixed=function(e){return t(this,2,e,this.e+e)},l.toPrecision=function(e){return t(this,3,e,e-1)},l.toString=function(){return t(this)},l.valueOf=l.toJSON=function(){return t(this,4)},(r=function t(){function n(e){var r=this;if(!(r instanceof n))return e===D?t():new n(e);e instanceof n?(r.s=e.s,r.e=e.e,r.c=e.c.slice()):function(e,r){var t,n,i;if(0===r&&1/r<0)r="-0";else if(!a.test(r+=""))throw Error(u+"number");for(e.s="-"==r.charAt(0)?(r=r.slice(1),-1):1,-1<(t=r.indexOf("."))&&(r=r.replace(".","")),0<(n=r.search(/e/i))?(t<0&&(t=n),t+=+r.slice(n+1),r=r.substring(0,n)):t<0&&(t=r.length),i=r.length,n=0;n<i&&"0"==r.charAt(n);)++n;if(n==i)e.c=[e.e=0];else{for(;0<i&&"0"==r.charAt(--i););for(e.e=t-n-1,e.c=[],t=0;n<=i;)e.c[t++]=+r.charAt(n++)}}(r,e),r.constructor=n}return n.prototype=l,n.DP=i,n.RM=s,n.NE=o,n.PE=f,n.version="5.2.0",n}()).default=r.Big=r,"function"==typeof define&&define.amd?define(function(){return r}):"undefined"!=typeof module&&module.exports?module.exports=r:e.Big=r}(this);

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

#### 5.2.0
* 09/10/18
* #63 Allow negative argument for `round`.
* #107 `sqrt` of large number.
#### 5.1.2

@@ -2,0 +8,0 @@

{
"name": "big.js",
"description": "A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic",
"version": "5.1.2",
"version": "5.2.1",
"keywords": [

@@ -19,3 +19,3 @@ "arbitrary",

],
"repository" : {
"repository": {
"type": "git",

@@ -31,3 +31,3 @@ "url": "https://github.com/MikeMcl/big.js.git"

},
"bugs": {
"bugs": {
"url": "https://github.com/MikeMcl/big.js/issues"

@@ -41,3 +41,4 @@ },

"test": "node ./test/every-test.js",
"build": "uglifyjs big.js --source-map doc/big.js.map -c -m -o big.min.js --preamble \"/* big.js v5.1.2 https://github.com/MikeMcl/big.js/LICENCE */\""
"build": "uglifyjs big.js --source-map -c -m -o big.min.js",
"postinstall": "opencollective postinstall"
},

@@ -48,3 +49,10 @@ "files": [

"big.min.js"
]
}
],
"dependencies": {
"opencollective": "^1.0.3"
},
"collective": {
"type": "opencollective",
"url": "https://opencollective.com/bigjs"
}
}

@@ -18,24 +18,29 @@ # big.js

## Install
## Set up
[Node.js](http://nodejs.org) users can install from the [npm](https://www.npmjs.com/package/big.js) registry using
The library is the single JavaScript file *big.js* (or *big.min.js*, which is *big.js* minified).
$ npm install --save big.js
Browser:
## Use
```html
<script src='path/to/big.js'></script>
```
The library is the single JavaScript file *big.js* (or *big.min.js*, which is *big.js* minified).
[Node.js](http://nodejs.org):
It can be loaded via a script tag in an HTML document for the browser
```bash
$ npm install big.js
```
<script src='./relative/path/to/big.js'></script>
```javascript
const Big = require('big.js');
```
or as a CommonJS, Node.js or AMD module using `require`.
ES6 module (*big.mjs*):
var Big = require('big.js');
```javascript
import Big from 'big.js';
```
## Use
If using an ES6 transpiler, or Node.js with the [`--experimental-modules`](https://nodejs.org/api/esm.html) flag, try
import Big from 'big.js';
*In all examples below, `var`, semicolons and `toString` calls are not shown. If a commented-out value is in quotes it means `toString` has been called on the preceding expression.*

@@ -71,3 +76,3 @@

The arithmetic methods always return the exact result except `div`, `sqrt` and `pow`
(with negative exponent), as these are the methods which involve division.
(with negative exponent), as these methods involve division.

@@ -118,3 +123,3 @@ The maximum number of decimal places and the rounding mode used to round the results of these methods is determined by the value of the `DP` and `RM` properties of the `Big` number constructor.

The *perf* directory contains two old applications and a *lib* directory containing the BigDecimal libraries used by both.
The *perf* directory contains two legacy applications and a *lib* directory containing the BigDecimal libraries used by both.

@@ -126,3 +131,3 @@ *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 BigDecimal in the npm registry is the GWT version. Despite its seeming popularity I have found it to have some serious bugs, see the Node.js script *perf/lib/bigdecimal_GWT/bugs.js* for examples of flaws in its *remainder*, *divide* and *compareTo* methods.
The BigDecimal in the npm registry is the GWT version. It has some bugs, see the Node.js script *perf/lib/bigdecimal_GWT/bugs.js* for examples of flaws in its *remainder*, *divide* and *compareTo* methods.

@@ -158,3 +163,3 @@ *bigtime.js* is a Node.js command-line application which tests the performance of big.js against the GWT version of

$ npm install --save @types/big.js
$ npm install @types/big.js

@@ -172,1 +177,31 @@ Any questions about the TypeScript type definitions file should be addressed to the DefinitelyTyped project.

[MIT](LICENCE)
## Contributors
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
<a href="graphs/contributors"><img src="https://opencollective.com/bigjs/contributors.svg?width=890&button=false" /></a>
## Backers
Thank you to all our backers! 🙏 [[Become a backer](https://opencollective.com/bigjs#backer)]
<a href="https://opencollective.com/bigjs#backers" target="_blank"><img src="https://opencollective.com/bigjs/backers.svg?width=890"></a>
## Sponsors
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [[Become a sponsor](https://opencollective.com/bigjs#sponsor)]
<a href="https://opencollective.com/bigjs/sponsor/0/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/bigjs/sponsor/1/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/bigjs/sponsor/2/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/bigjs/sponsor/3/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/bigjs/sponsor/4/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/bigjs/sponsor/5/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/bigjs/sponsor/6/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/bigjs/sponsor/7/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/bigjs/sponsor/8/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/bigjs/sponsor/9/website" target="_blank"><img src="https://opencollective.com/bigjs/sponsor/9/avatar.svg"></a>

Sorry, the diff of this file is not supported yet

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