Socket
Socket
Sign inDemoInstall

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 2.0.0 to 2.1.0

14

big.js

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

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

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

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

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

*
* 0 Round towards zero (i.e. truncate, no rounding). (ROUND_DOWN )
* 1 Round to nearest neighbour. If equidistant, round up. (ROUND_HALF_UP )
* 0 Round towards zero (i.e. truncate, no rounding). (ROUND_DOWN)
* 1 Round to nearest neighbour. If equidistant, round up. (ROUND_HALF_UP)
* 2 Round to nearest neighbour. If equidistant, to even neighbour. (ROUND_HALF_EVEN)

@@ -60,3 +60,3 @@ */

P = Big.prototype,
isValid = /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,
isValid = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
ONE = new Big(1);

@@ -451,3 +451,3 @@

var xc = x['c'],
var xc = x['c'].slice(),
xe = x['e'],

@@ -472,3 +472,3 @@ yc = y['c'],

// Prepend zeros to equalise exponents.
if ( xc = xc.slice(), a = xe - ye ) {
if ( a = xe - ye ) {
d = ( xLTy = a < 0 ) ? ( a = -a, xc ) : ( ye = xe, yc );

@@ -475,0 +475,0 @@

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

/* big.js v2.0.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+)?(?:e[+-]?\d+)?$/i,s=new t(1);i.abs=function(){return new t(this)},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,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(i=i.slice(),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.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)
{
"name": "big.js",
"description": "A small, fast, easy-to-use library for arbitrary-precision decimal arithmetic",
"version": "2.0.0",
"version": "2.1.0",
"keywords": [

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

@@ -174,5 +174,9 @@

####2.1.0
* 26/06/13 Allow e.g. `.1` and `2.`.
####2.0.0
* 12 May 2013 Added `abs` method and replaced `cmp` with `eq`, `gt`, `gte`, `lt`, and `lte` methods.
* 12/05/13 Added `abs` method and replaced `cmp` with `eq`, `gt`, `gte`, `lt`, and `lte` methods.

@@ -179,0 +183,0 @@ ####1.0.1

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

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc