Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

big.js

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

big.js - npm Package Compare versions

Comparing version 5.0.1 to 5.0.2

CHANGELOG.md

10

big.js
/*
* big.js v5.0.1
* big.js v5.0.2
* A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic.

@@ -74,3 +74,3 @@ * Copyright (c) 2017 Michael Mclaughlin <M8ch88l@gmail.com>

*/
function factory() {
function _Big_() {

@@ -87,3 +87,3 @@ /*

// Enable constructor usage without new.
if (!(x instanceof Big)) return n === UNDEFINED ? factory() : new Big(n);
if (!(x instanceof Big)) return n === UNDEFINED ? _Big_() : new Big(n);

@@ -111,3 +111,3 @@ // Duplicate.

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

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

Big = factory();
Big = _Big_();

@@ -922,0 +922,0 @@ Big['default'] = Big.Big = Big;

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

/* big.js v5.0.1 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===v?r():new e(n)}return e.prototype=d,e.DP=s,e.RM=f,e.NE=h,e.PE=l,e.version="5.0.1",e}function t(e,r){var t,n,i;if(0===r&&0>1/r)r="-0";else if(!m.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(1===t)n=i[o]>=5;else if(2===t)n=i[o]>5||5==i[o]&&(n||0>o||i[o+1]!==v||1&i[o-1]);else if(3===t)n=n||i[o]!==v||0>o;else if(n=!1,0!==t)throw Error(g+"rounding mode");if(1>o||!i[0])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()}return e}function i(e,r,t,i){var o,s,f=e.constructor,u=!e.c[0];if(t!==v){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=a+"Division by zero",d={},v=void 0,m=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;d.abs=function(){var e=new this.constructor(this);return e.s=1,e},d.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},d.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(w);if(!i[0])return new t(0*s);var u,h,l,a,g,d=o.slice(),m=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,d.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:d;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[m]||0:M=[i[m]]}while((m++<E||M[0]!==v)&&s--);return D[0]||1==R||(D.shift(),b.e--),R>A&&n(b,f,t.RM,M[0]!==v),b},d.eq=function(e){return!this.cmp(e)},d.gt=function(e){return this.cmp(e)>0},d.gte=function(e){return this.cmp(e)>-1},d.lt=function(e){return this.cmp(e)<0},d.lte=function(e){return this.cmp(e)<1},d.minus=d.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},d.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(w);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)))},d.plus=d.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},d.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},d.round=function(e,r){var t=this.constructor;if(e===v)e=0;else if(e!==~~e||0>e||e>c)throw Error(p);return n(new t(this),e,r===v?t.RM:r)},d.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)},d.times=d.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},d.toExponential=function(e){return i(this,1,e,e)},d.toFixed=function(e){return i(this,2,e,this.e+e)},d.toPrecision=function(e){return i(this,3,e,e-1)},d.toString=function(){return i(this)},d.valueOf=d.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);
/* big.js v5.0.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===v?r():new e(n)}return e.prototype=d,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(!m.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(1===t)n=i[o]>=5;else if(2===t)n=i[o]>5||5==i[o]&&(n||0>o||i[o+1]!==v||1&i[o-1]);else if(3===t)n=n||i[o]!==v||0>o;else if(n=!1,0!==t)throw Error(g+"rounding mode");if(1>o||!i[0])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()}return e}function i(e,r,t,i){var o,s,f=e.constructor,u=!e.c[0];if(t!==v){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=a+"Division by zero",d={},v=void 0,m=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;d.abs=function(){var e=new this.constructor(this);return e.s=1,e},d.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},d.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(w);if(!i[0])return new t(0*s);var u,h,l,a,g,d=o.slice(),m=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,d.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:d;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[m]||0:M=[i[m]]}while((m++<E||M[0]!==v)&&s--);return D[0]||1==R||(D.shift(),b.e--),R>A&&n(b,f,t.RM,M[0]!==v),b},d.eq=function(e){return!this.cmp(e)},d.gt=function(e){return this.cmp(e)>0},d.gte=function(e){return this.cmp(e)>-1},d.lt=function(e){return this.cmp(e)<0},d.lte=function(e){return this.cmp(e)<1},d.minus=d.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},d.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(w);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)))},d.plus=d.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},d.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},d.round=function(e,r){var t=this.constructor;if(e===v)e=0;else if(e!==~~e||0>e||e>c)throw Error(p);return n(new t(this),e,r===v?t.RM:r)},d.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)},d.times=d.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},d.toExponential=function(e){return i(this,1,e,e)},d.toFixed=function(e){return i(this,2,e,this.e+e)},d.toPrecision=function(e){return i(this,3,e,e-1)},d.toString=function(){return i(this)},d.valueOf=d.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
{
"name": "big.js",
"description": "A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic",
"version": "5.0.1",
"version": "5.0.2",
"keywords": [

@@ -37,3 +37,3 @@ "arbitrary",

"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.0.1 https://github.com/MikeMcl/big.js/LICENCE */\""
"build": "uglifyjs big.js --source-map doc/big.js.map -c -m -o big.min.js --preamble \"/* big.js v5.0.2 https://github.com/MikeMcl/big.js/LICENCE */\""
},

@@ -40,0 +40,0 @@ "files": [

@@ -0,8 +1,6 @@

# big.js
# big.js #
A small, fast JavaScript library for arbitrary-precision decimal arithmetic.
**A small, fast JavaScript library for arbitrary-precision decimal arithmetic.**
The little sister to [bignumber.js](https://github.com/MikeMcl/bignumber.js/).
See also [decimal.js](https://github.com/MikeMcl/decimal.js/), and [here](https://github.com/MikeMcl/big.js/wiki) for the difference between them.
The little sister to [bignumber.js](https://github.com/MikeMcl/bignumber.js/) and [decimal.js](https://github.com/MikeMcl/decimal.js/). See [here](https://github.com/MikeMcl/big.js/wiki) for some notes on the difference between them.

@@ -20,4 +18,10 @@ ## Features

## Load
## Install
[Node.js](http://nodejs.org) users can install from the [npm](https://www.npmjs.com/package/big.js) registry using
$ npm install --save big.js
## Use
The library is the single JavaScript file *big.js* (or *big.min.js*, which is *big.js* minified).

@@ -29,20 +33,15 @@

or as a CommonJS, [Node.js](http://nodejs.org) or AMD module using `require`.
or as a CommonJS, Node.js or AMD module using `require`.
var Big = require('big.js');
For Node.js, the library is available from the npm registry:
If using an ES6 transpiler, or Node.js with the [`--experimental-modules`](https://nodejs.org/api/esm.html) flag, try
$ npm install big.js
import Big from './big';
*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.*
The library exports a single function, `Big`, the constructor of Big number instances.
It accepts a value of type number, string or Big number object.
## Use
*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.*
The library exports a single function: Big, the constructor of Big number instances.
It accepts a value of type Number, String or Big number Object.
x = new Big(123.4567)

@@ -72,9 +71,7 @@ y = Big('123456.7e-3') // 'new' is optional

The maximum number of decimal places and the rounding mode used to round the results of the `div`, `sqrt` and `pow`
(with negative exponent) methods is determined by the value of the `DP` and `RM` properties of the `Big` number constructor.
The arithmetic methods always return the exact result except `div`, `sqrt` and `pow`
(with negative exponent), as these are the methods which involve division.
The other methods always give the exact result.
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.
(From *v3.0.0*, multiple Big number constructors can be created, see Change Log below.)
Big.DP = 10

@@ -91,2 +88,3 @@ Big.RM = 1

Multiple Big number constructors can be created, each with an independent configuration.

@@ -106,34 +104,31 @@ The value of a Big number is stored in a decimal floating point format in terms of a coefficient, exponent and sign.

The tests can be run with Node or a browser.
The tests can be run with Node.js or a browser.
To test a single method, from a command-line shell at the *test* directory, use e.g.
To run all the tests
$ node toFixed
$ npm test
To test all the methods
To test a single method
$ node every-test
$ node test/toFixed
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* is a simple application that enables some of the methods of big.js to be compared with those of JavaScript's Number type.
## Performance
The *perf* directory contains two applications and a *lib* directory containing the BigDecimal libraries used by both.
The *perf* directory contains two old applications and a *lib* directory containing the BigDecimal libraries used by both.
*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.)
* GWT: java.math.BigDecimal
<https://github.com/iriscouch/bigdecimal.js>
* ICU4J: com.ibm.icu.math.BigDecimal
<https://github.com/dtrebbien/BigDecimal.js>
* [GWT: java.math.BigDecimal](https://github.com/iriscouch/bigdecimal.js)
* [ICU4J: com.ibm.icu.math.BigDecimal](https://github.com/dtrebbien/BigDecimal.js)
The BigDecimal in Node's npm registry is the GWT version. Despite its seeming popularity I have found it to have some serious bugs, see the Node 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. 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.
*bigtime.js* is a Node command-line application which tests the performance of big.js against the GWT version of
*bigtime.js* is a Node.js command-line application which tests the performance of big.js against the GWT version of
BigDecimal from the npm registry.
For example, to compare the time taken by the big.js `plus` method and the BigDecimal `add` method:
For example, to compare the time taken by the big.js `plus` method and the BigDecimal `add` method

@@ -144,3 +139,3 @@ $ node bigtime plus 10000 40

For help:
For help

@@ -151,8 +146,10 @@ $ node bigtime -h

I.e. minify.
If [uglify-js](https://github.com/mishoo/UglifyJS2) is installed globally
For Node, if uglify-js is installed globally ( `npm install uglify-js -g` ) then
$ npm install uglify-js -g
uglifyjs -o ./big.min.js ./big.js
then
$ npm run build
will create *big.min.js*.

@@ -162,129 +159,16 @@

The [DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped) project has a TypeScript [definitions file](https://github.com/borisyankov/DefinitelyTyped/blob/master/big.js/big.js.d.ts) for big.js.
The [DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped) project has a Typescript type definitions file for big.js.
The definitions file can be added to your project via the [big.js.TypeScript.DefinitelyTyped](https://www.nuget.org/packages/big.js.TypeScript.DefinitelyTyped/0.0.1) NuGet package or via [tsd](http://definitelytyped.org/tsd/).
$ npm install --save @types/big.js
tsd query big.js --action install
Any questions about the TypeScript type definitions file should be addressed to the DefinitelyTyped project.
Any questions about the TypeScript definitions file should be addressed to the DefinitelyTyped project.
## Feedback
Feedback is welcome.
Bugs/comments/questions?
Open an issue, or email
Michael
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a>
Open an issue, or email <a href="mailto:M8ch88l@gmail.com">Michael</a>
## Licence
See LICENCE.
## Change Log
####5.0.1
* 13/10/17
* Correct `Big.version` number.
####5.0.0
* 13/10/17
* Return `-0` from `valueOf` for negative zero.
* Refactor the methods which return a string.
* Amend error messaging.
* Update API document and change its colour scheme.
* Add `Big.version`.
* Remove bitcoin address.
####4.0.2
* 28/09/17
* Add *big.mjs* for use with Node.js with `--experimental-modules` flag.
####4.0.0
* 27/09/17
* Rename `Big.E_POS` to `Big.PE`, `Big.E_NEG` to `Big.NE`.
* Refactor error messaging.
* Throw if `null` is passed to `toFixed` etc.
####3.2.0
* 14/09/17 Aid ES6 import.
####3.1.3
* Minor documentation updates.
####3.1.2
* README typo.
####3.1.1
* API documentation update, including FAQ additions.
####3.1.0
* Renamed and exposed `TO_EXP_NEG` and `TO_EXP_POS` as `Big.E_NEG` and `Big.E_POS`.
####3.0.2
* Remove *.npmignore*, use `files` field in *package.json* instead.
####3.0.1
* Added `sub`, `add` and `mul` aliases.
* Clean-up after lint.
####3.0.0
* 10/12/14 Added [multiple constructor functionality](http://mikemcl.github.io/big.js/#faq).
* No breaking changes or other additions, but a major code reorganisation, so *v3* seemed appropiate.
####2.5.2
* 1/11/14 Added bower.json.
####2.5.1
* 8/06/14 Amend README requires.
####2.5.0
* 26/01/14 Added `toJSON` method so serialization uses `toString`.
####2.4.1
* 17/10/13 Conform signed zero to IEEEE 754 (2008).
####2.4.0
* 19/09/13 Throw instances of `Error`.
####2.3.0
* 16/09/13 Added `cmp` method.
####2.2.0
* 11/07/13 Added 'round up' mode.
####2.1.0
* 26/06/13 Allow e.g. `.1` and `2.`.
####2.0.0
* 12/05/13 Added `abs` method and replaced `cmp` with `eq`, `gt`, `gte`, `lt`, and `lte` methods.
####1.0.1
* Changed default value of MAX_DP to 1E6
####1.0.0
* 7/11/2012 Initial release
[MIT](LICENCE)

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc