Socket
Socket
Sign inDemoInstall

big-integer

Package Overview
Dependencies
0
Maintainers
1
Versions
102
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0 to 1.0.1

BigInt.v11.suo

2

BigInteger.min.js

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

var bigInt=function(){var e=1e7,t=7,n={positive:!1,negative:!0},r=function(e,t){var n=e.value,r=t.value,i=n.length>r.length?n.length:r.length;for(var s=0;s<i;s++)n[s]=n[s]||0,r[s]=r[s]||0;for(var s=i-1;s>=0;s--)n[s]===0&&r[s]===0&&(n.pop(),r.pop());e.value=n,t.value=r},i=function(e,s){if(typeof e=="object")return e;e+="";var u=n.positive,a=[];e[0]==="-"&&(u=n.negative,e=e.slice(1));var e=e.split("e");if(e.length>2)throw new Error("Invalid integer");if(e[1]){var f=e[1];f[0]==="+"&&(f=f.slice(1)),f=i(f);if(f.lesser(0))throw new Error("Cannot include negative exponent part for integers");while(f.notEquals(0))e[0]+="0",f=f.prev()}e=e[0],e==="-0"&&(e="0");var l=/^([1-9][0-9]*)$|^0$/.test(e);if(!l)throw new Error("Invalid integer");while(e.length){var c=e.length>t?e.length-t:0;a.push(+e.slice(c)),e=e.slice(0,c)}var h=o(a,u);return s&&r(s,h),h},s=function(e,t){var e=o(e,n.positive),t=o(t,n.positive),r=0;do{var i=1,s=o(e.value,n.positive),u=s.times(10);while(u.lesser(t))s=u,i*=10,u=u.times(10);while(s.lesserOrEquals(t))t=t.minus(s),r+=i}while(e.lesserOrEquals(t));return{remainder:t.value,result:r}},o=function(t,f){var l={value:t,sign:f},c={value:t,sign:f,negate:function(e){var t=e||l;return o(t.value,!t.sign)},abs:function(e){var t=e||l;return o(t.value,n.positive)},add:function(t,s){var u,a=l,f;s?(a=i(t))&&(f=i(s)):f=i(t,a),u=a.sign;if(a.sign!==f.sign)return a=o(a.value,n.positive),f=o(f.value,n.positive),u===n.positive?c.subtract(a,f):c.subtract(f,a);r(a,f);var h=a.value,p=f.value,d=[],v=0;for(var m=0;m<h.length||v>0;m++){var g=h[m]+p[m]+v;v=g>e?1:0,g-=v*e,d.push(g)}return o(d,u)},plus:function(e,t){return c.add(e,t)},subtract:function(t,r){var s,u=l,a;r?(u=i(t))&&(a=i(r)):a=i(t,u);if(u.sign!==a.sign)return c.add(u,c.negate(a));if(u.sign===n.negative)return c.subtract(c.negate(a),c.negate(u));if(c.compare(u,a)===-1)return c.negate(c.subtract(a,u));var f=u.value,h=a.value,p=[],d=0;for(var v=0;v<f.length;v++){f[v]-=d,d=f[v]<h[v]?1:0;var m=d*e+f[v]-h[v];p.push(m)}return o(p,n.positive)},minus:function(e,t){return c.subtract(e,t)},multiply:function(t,n){var r,s=l,u;n?(s=i(t))&&(u=i(n)):u=i(t,s),r=s.sign!==u.sign;var a=s.value,f=u.value,c=[];for(var h=0;h<a.length;h++){c[h]=[];var p=h;while(p--)c[h].push(0)}var d=0;for(var h=0;h<a.length;h++){var v=a[h];for(var p=0;p<f.length||d>0;p++){var m=f[p],g=m?v*m+d:d;d=g>e?Math.floor(g/e):0,g-=d*e,c[h].push(g)}}var y=-1;for(var h=0;h<c.length;h++){var b=c[h].length;b>y&&(y=b)}var w=[],d=0;for(var h=0;h<y||d>0;h++){var E=d;for(var p=0;p<c.length;p++)E+=c[p][h]||0;d=E>e?Math.floor(E/e):0,E-=d*e,w.push(E)}return o(w,r)},times:function(e,t){return c.multiply(e,t)},divmod:function(e,t){var n,r=l,u;t?(r=i(e))&&(u=i(t)):u=i(e,r),n=r.sign!==u.sign;if(u.equals(0))throw new Error("Cannot divide by zero");var a=r.value,f=u.value,c=[],h=[];for(var p=a.length-1;p>=0;p--){var e=[a[p]].concat(h),d=s(f,e);c.push(d.result),h=d.remainder}return c.reverse(),{quotient:o(c,n),remainder:o(h,r.sign)}},divide:function(e,t){return c.divmod(e,t).quotient},over:function(e,t){return c.divide(e,t)},mod:function(e,t){return c.divmod(e,t).remainder},pow:function(e,t){var n=l,r;t?(n=i(e))&&(r=i(t)):r=i(e,n);var s=n,c=r;if(c.lesser(0))return u;if(c.equals(0))return a;var h=o(s.value,s.sign);while(c.greater(1))h=h.times(s),c=c.prev();return o(h.value,f)},next:function(e){var t=e||l;return c.add(t,1)},prev:function(e){var t=e||l;return c.subtract(t,1)},compare:function(e,t){var s=l,o;t?(s=i(e))&&(o=i(t,s)):o=i(e,s);if(o.sign!==s.sign)return s.sign===n.positive?1:-1;var u=s.sign===n.positive?1:-1;r(s,o);var a=s.value,f=o.value;for(var c=a.length-1;c>=0;c--){if(a[c]>f[c])return 1*u;if(f[c]>a[c])return-1*u}return 0},compareAbs:function(e,t){var r=l,s;return t?(r=i(e))&&(s=i(t,r)):s=i(e,r),r.sign=s.sign=n.positive,c.compare(r,s)},equals:function(e,t){return c.compare(e,t)===0},notEquals:function(e,t){return!c.equals(e,t)},lesser:function(e,t){return c.compare(e,t)<0},greater:function(e,t){return c.compare(e,t)>0},greaterOrEquals:function(e,t){return c.compare(e,t)>=0},lesserOrEquals:function(e,t){return c.compare(e,t)<=0},toString:function(e){var t=e||l,r="",i=t.value.length;while(i--)r+=t.value[i];while(r[0]==="0")r=r.slice(1);r.length||(r="0");var s=t.sign===n.positive?"":"-";return s+r},toJSNumber:function(e){return+c.toString(e)},valueOf:function(e){return c.toJSNumber(e)}};return c},u=o([0],n.positive),a=o([1],n.positive),f=o([-1],n.positive),l=function(e){return typeof e=="undefined"?u:i(e)};return l.zero=u,l.one=a,l.minusOne=f,l}();
var bigInt=function(){var e=1e7,t=7,n={positive:!1,negative:!0},r=function(e,t){var n=e.value,r=t.value,i=n.length>r.length?n.length:r.length;for(var s=0;s<i;s++)n[s]=n[s]||0,r[s]=r[s]||0;for(var s=i-1;s>=0;s--)n[s]===0&&r[s]===0&&(n.pop(),r.pop());e.value=n,t.value=r},i=function(e,s){if(typeof e=="object")return e;e+="";var u=n.positive,a=[];e[0]==="-"&&(u=n.negative,e=e.slice(1));var e=e.split("e");if(e.length>2)throw new Error("Invalid integer");if(e[1]){var f=e[1];f[0]==="+"&&(f=f.slice(1)),f=i(f);if(f.lesser(0))throw new Error("Cannot include negative exponent part for integers");while(f.notEquals(0))e[0]+="0",f=f.prev()}e=e[0],e==="-0"&&(e="0");var l=/^([1-9][0-9]*)$|^0$/.test(e);if(!l)throw new Error("Invalid integer");while(e.length){var c=e.length>t?e.length-t:0;a.push(+e.slice(c)),e=e.slice(0,c)}var h=o(a,u);return s&&r(s,h),h},s=function(e,t){var e=o(e,n.positive),t=o(t,n.positive),r=0;do{var i=1,s=o(e.value,n.positive),u=s.times(10);while(u.lesser(t))s=u,i*=10,u=u.times(10);while(s.lesserOrEquals(t))t=t.minus(s),r+=i}while(e.lesserOrEquals(t));return{remainder:t.value,result:r}},o=function(t,f){var l={value:t,sign:f},c={value:t,sign:f,negate:function(e){var t=e||l;return o(t.value,!t.sign)},abs:function(e){var t=e||l;return o(t.value,n.positive)},add:function(t,s){var u,a=l,f;s?(a=i(t))&&(f=i(s)):f=i(t,a),u=a.sign;if(a.sign!==f.sign)return a=o(a.value,n.positive),f=o(f.value,n.positive),u===n.positive?c.subtract(a,f):c.subtract(f,a);r(a,f);var h=a.value,p=f.value,d=[],v=0;for(var m=0;m<h.length||v>0;m++){var g=h[m]+p[m]+v;v=g>e?1:0,g-=v*e,d.push(g)}return o(d,u)},plus:function(e,t){return c.add(e,t)},subtract:function(t,r){var s,u=l,a;r?(u=i(t))&&(a=i(r)):a=i(t,u);if(u.sign!==a.sign)return c.add(u,c.negate(a));if(u.sign===n.negative)return c.subtract(c.negate(a),c.negate(u));if(c.compare(u,a)===-1)return c.negate(c.subtract(a,u));var f=u.value,h=a.value,p=[],d=0;for(var v=0;v<f.length;v++){f[v]-=d,d=f[v]<h[v]?1:0;var m=d*e+f[v]-h[v];p.push(m)}return o(p,n.positive)},minus:function(e,t){return c.subtract(e,t)},multiply:function(t,n){var r,s=l,u;n?(s=i(t))&&(u=i(n)):u=i(t,s),r=s.sign!==u.sign;var a=s.value,f=u.value,c=[];for(var h=0;h<a.length;h++){c[h]=[];var p=h;while(p--)c[h].push(0)}var d=0;for(var h=0;h<a.length;h++){var v=a[h];for(var p=0;p<f.length||d>0;p++){var m=f[p],g=m?v*m+d:d;d=g>e?Math.floor(g/e):0,g-=d*e,c[h].push(g)}}var y=-1;for(var h=0;h<c.length;h++){var b=c[h].length;b>y&&(y=b)}var w=[],d=0;for(var h=0;h<y||d>0;h++){var E=d;for(var p=0;p<c.length;p++)E+=c[p][h]||0;d=E>e?Math.floor(E/e):0,E-=d*e,w.push(E)}return o(w,r)},times:function(e,t){return c.multiply(e,t)},divmod:function(e,t){var n,r=l,u;t?(r=i(e))&&(u=i(t)):u=i(e,r),n=r.sign!==u.sign;if(u.equals(0))throw new Error("Cannot divide by zero");var a=r.value,f=u.value,c=[],h=[];for(var p=a.length-1;p>=0;p--){var e=[a[p]].concat(h),d=s(f,e);c.push(d.result),h=d.remainder}return c.reverse(),{quotient:o(c,n),remainder:o(h,r.sign)}},divide:function(e,t){return c.divmod(e,t).quotient},over:function(e,t){return c.divide(e,t)},mod:function(e,t){return c.divmod(e,t).remainder},pow:function(e,t){var n=l,r;t?(n=i(e))&&(r=i(t)):r=i(e,n);var s=n,c=r;if(c.lesser(0))return u;if(c.equals(0))return a;var h=o(s.value,s.sign);while(c.greater(1))h=h.times(s),c=c.prev();return o(h.value,f)},next:function(e){var t=e||l;return c.add(t,1)},prev:function(e){var t=e||l;return c.subtract(t,1)},compare:function(e,t){var s=l,o;t?(s=i(e))&&(o=i(t,s)):o=i(e,s);if(o.sign!==s.sign)return s.sign===n.positive?1:-1;var u=s.sign===n.positive?1:-1;r(s,o);var a=s.value,f=o.value;for(var c=a.length-1;c>=0;c--){if(a[c]>f[c])return 1*u;if(f[c]>a[c])return-1*u}return 0},compareAbs:function(e,t){var r=l,s;return t?(r=i(e))&&(s=i(t,r)):s=i(e,r),r.sign=s.sign=n.positive,c.compare(r,s)},equals:function(e,t){return c.compare(e,t)===0},notEquals:function(e,t){return!c.equals(e,t)},lesser:function(e,t){return c.compare(e,t)<0},greater:function(e,t){return c.compare(e,t)>0},greaterOrEquals:function(e,t){return c.compare(e,t)>=0},lesserOrEquals:function(e,t){return c.compare(e,t)<=0},toString:function(e){var t=e||l,r="",i=t.value.length;while(i--)r+=t.value[i];while(r[0]==="0")r=r.slice(1);r.length||(r="0");var s=t.sign===n.positive?"":"-";return s+r},toJSNumber:function(e){return+c.toString(e)},valueOf:function(e){return c.toJSNumber(e)}};return c},u=o([0],n.positive),a=o([1],n.positive),f=o([-1],n.positive),l=function(e){return typeof e=="undefined"?u:i(e)};return l.zero=u,l.one=a,l.minusOne=f,l}();typeof module!="undefined"&&(module.exports=bigInt);
{
"name": "big-integer",
"version": "1.0.0",
"version": "1.0.1",
"author": "Peter Olson <peter.e.c.olson+npm@gmail.com>",

@@ -5,0 +5,0 @@ "description": "An arbitrary length integer library for Javascript",

@@ -6,4 +6,14 @@ BigInteger.js

You can download [BigInteger.js from GitHub](http://peterolson.github.com/BigInteger.js/BigInteger.min.js).
If you are using a browser, you can download [BigInteger.js from GitHub](http://peterolson.github.com/BigInteger.js/BigInteger.min.js) or just hotlink to it:
<script src="http://peterolson.github.com/BigInteger.js/BigInteger.min.js"></script>
If you are using node, you can install BigInteger with [npm](https://npmjs.org/).
npm install big-integer
Then you can include it in your code:
var bigInt = require("big-integer");
`bigInt(number)`

@@ -10,0 +20,0 @@ ---

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc