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.3.16 to 1.3.17

92

BigInteger.js

@@ -321,2 +321,3 @@ "use strict";

}
if (radix !== 10) return toBase(this, radix);
var first = this;

@@ -327,46 +328,5 @@ var str = "", len = first.value.length;

}
if (radix === 10) {
while (len--) {
if (first.value[len].toString().length === 8) str += first.value[len];
else str += (base.toString() + first.value[len]).slice(-logBase);
}
} else {
var groupLength = 0;
var groupRadix = 1;
var y = Math.floor(base / radix);
while (y >= groupRadix) {
groupLength += 1;
groupRadix *= radix;
}
var size = len + Math.floor((len - 1) / groupLength) + 1;
var remainder = [];
var n = -1;
while (++n < len) {
remainder[n] = first.value[n];
}
var k = size;
while (len !== 0) {
var carry = 0;
var i = len;
while (--i >= 0) {
carry = carry * base + remainder[i];
var q = Math.floor(carry / groupRadix);
remainder[i] = q;
carry -= q * groupRadix;
}
while (len !== 0 && remainder[len - 1] === 0) {
len -= 1;
}
k -= 1;
remainder[k] = carry;
}
str += remainder[k].toString(radix);
while (++k < size) {
var t = remainder[k].toString(radix);
var j = groupLength - t.length;
while (--j >= 0) {
str += "0";
}
str += t;
}
while (len--) {
if (first.value[len].toString().length === 8) str += first.value[len];
else str += (base.toString() + first.value[len]).slice(-logBase);
}

@@ -484,2 +444,46 @@ while (str[0] === "0") {

function stringify(digit) {
var v = digit.value;
if (v.length === 1 && v[0] <= 36) {
return "0123456789abcdefghijklmnopqrstuvwxyz".charAt(v[0]);
}
return "<" + v + ">";
}
function toBase(n, base) {
base = bigInt(base);
if (base.equals(0)) {
if (n.equals(0)) return "0";
throw new Error("Cannot convert nonzero numbers to base 0.");
}
if (base.equals(-1)) {
if (n.equals(0)) return "0";
if (n.lesser(0)) return Array(1 - n).join("10");
return "1" + Array(+n).join("01");
}
var minusSign = "";
if (n.isNegative() && base.isPositive()) {
minusSign = "-";
n = n.abs();
}
if (base.equals(1)) {
if (n.equals(0)) return "0";
return minusSign + Array(+n + 1).join(1);
}
var out = [];
var left = n, divmod;
while (left.lesser(0) || left.compareAbs(base) >= 0) {
divmod = left.divmod(base);
left = divmod.quotient;
var digit = divmod.remainder;
if (digit.lesser(0)) {
digit = base.minus(digit).abs();
left = left.next();
}
out.push(stringify(digit));
}
out.push(stringify(left));
return minusSign + out.reverse().join("");
}
var fnReturn = function (a, b) {

@@ -486,0 +490,0 @@ if (typeof a === "undefined") return ZERO;

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

"use strict";var bigInt=function(){function r(e,t){this.value=e,this.sign=t}function i(e){var t=[],n=0;for(var r=e.length-1;r>=0;r--){if(r>n&&e[r]===0)continue;n=r,t[r]=e[r]}return t}function s(e,t){return e=d(e).abs(),t=d(t).abs(),e.equals(t)?e:e.equals(c)?t:t.equals(c)?e:e.isEven()?t.isOdd()?s(e.divide(2),t):s(e.divide(2),t.divide(2)).multiply(2):t.isEven()?s(e,t.divide(2)):e.greater(t)?s(e.subtract(t).divide(2),t):s(t.subtract(e).divide(2),e)}function o(e,t){return e=d(e).abs(),t=d(t).abs(),e.multiply(t).divide(s(e,t))}function u(e,t){return e=d(e),t=d(t),e.greater(t)?e:t}function a(e,t){return e=d(e),t=d(t),e.lesser(t)?e:t}function f(t,n){t=d(t),n=d(n);var i=a(t,n),s=u(t,n),o=s.subtract(i),f=o.value.length-1,l=[],c=!0;for(var h=f;h>=0;h--){var p=c?o.value[h]:e,v=Math.floor(Math.random()*p);l.unshift(v),v<p&&(c=!1)}return i.add(new r(l,!1))}function d(i){if(i instanceof r)return i;if(Math.abs(+i)<e&&+i===(+i|0)){var s=+i;return new r([Math.abs(s)],s<0||1/s===-Infinity)}i+="";var o=n.positive,s=[];i[0]==="-"&&(o=n.negative,i=i.slice(1));var i=i.split(/e/i);if(i.length>2)throw new Error("Invalid integer: "+i.join("e"));if(i[1]){var u=i[1];u[0]==="+"&&(u=u.slice(1)),u=d(u);if(u.lesser(0))throw new Error("Cannot include negative exponent part for integers");while(u.notEquals(0))i[0]+="0",u=u.prev()}i=i[0],i==="-0"&&(i="0");var a=/^([0-9][0-9]*)$/.test(i);if(!a)throw new Error("Invalid integer: "+i);while(i.length){var f=i.length>t?i.length-t:0;s.push(+i.slice(f)),i=i.slice(0,f)}return new r(s,o)}var e=1e7,t=7,n={positive:!1,negative:!0};r.prototype.negate=function(){return new r(this.value,!this.sign)},r.prototype.abs=function(){return new r(this.value,n.positive)},r.prototype.add=function(t){t=d(t);if(this.sign!==t.sign)return this.sign===n.positive?this.abs().subtract(t.abs()):t.abs().subtract(this.abs());var s=this.value,o=t.value,u=[],a=0,f=Math.max(s.length,o.length);for(var l=0;l<f||a>0;l++){var c=(s[l]||0)+(o[l]||0)+a;a=c>=e?1:0,c-=a*e,u.push(c)}return new r(i(u),this.sign)},r.prototype.plus=function(e){return this.add(e)},r.prototype.subtract=function(t){t=d(t);if(this.sign!==t.sign)return this.add(t.negate());if(this.sign===n.negative)return t.negate().subtract(this.negate());if(this.compare(t)<0)return t.subtract(this).negate();var s=this.value,o=t.value,u=[],a=0,f=Math.max(s.length,o.length);for(var l=0;l<f;l++){var c=s[l]||0,h=o[l]||0,p=c-a;a=p<h?1:0;var v=a*e+p-h;u.push(v)}return new r(i(u),n.positive)},r.prototype.minus=function(e){return this.subtract(e)},r.prototype.multiply=function(t){t=d(t);var n=this.sign!==t.sign,s=this.value,o=t.value,u=Math.max(s.length,o.length),a=[];for(var f=0;f<u;f++){a[f]=[];var l=f;while(l--)a[f].push(0)}var c=0;for(var f=0;f<s.length;f++){var h=s[f];for(var l=0;l<o.length||c>0;l++){var p=o[l],v=p?h*p+c:c;c=v>e?Math.floor(v/e):0,v-=c*e,a[f].push(v)}}var m=-1;for(var f=0;f<a.length;f++){var g=a[f].length;g>m&&(m=g)}var y=[],c=0;for(var f=0;f<m||c>0;f++){var b=c;for(var l=0;l<a.length;l++)b+=a[l][f]||0;c=b>e?Math.floor(b/e):0,b-=c*e,y.push(b)}return new r(i(y),n)},r.prototype.times=function(e){return this.multiply(e)},r.prototype.divmod=function(e){e=d(e);var t=this.sign!==e.sign;if(this.equals(0))return{quotient:new r([0],n.positive),remainder:new r([0],n.positive)};if(e.equals(0))throw new Error("Cannot divide by zero");var s=this.value,o=e.value,u=[],a=[];for(var f=s.length-1;f>=0;f--){var c=[s[f]].concat(a),h=l(o,c);u.push(h.result),a=h.remainder}return u.reverse(),{quotient:new r(i(u),t),remainder:new r(i(a),this.sign)}},r.prototype.divide=function(e){return this.divmod(e).quotient},r.prototype.over=function(e){return this.divide(e)},r.prototype.mod=function(e){return this.divmod(e).remainder},r.prototype.remainder=function(e){return this.mod(e)},r.prototype.pow=function(e){e=d(e);var t=this,n=e,r=h;if(n.equals(c))return r;if(t.equals(c)||n.lesser(c))return c;for(;;){n.isOdd()&&(r=r.times(t)),n=n.divide(2);if(n.equals(c))break;t=t.times(t)}return r},r.prototype.modPow=function(e,t){e=d(e),t=d(t);if(t.equals(c))throw new Error("Cannot take modPow with modulus 0");var n=h,r=this.mod(t);if(r.equals(c))return c;while(e.greater(0))e.isOdd()&&(n=n.multiply(r).mod(t)),e=e.divide(2),r=r.square().mod(t);return n},r.prototype.square=function(){return this.multiply(this)},r.prototype.next=function(){return this.add(1)},r.prototype.prev=function(){return this.subtract(1)},r.prototype.compare=function(e){var t=this,r=d(e);if(t.value.length===1&&r.value.length===1&&t.value[0]===0&&r.value[0]===0)return 0;if(r.sign!==t.sign)return t.sign===n.positive?1:-1;var i=t.sign===n.positive?1:-1,s=t.value,o=r.value,u=Math.max(s.length,o.length)-1;for(var a=u;a>=0;a--){var f=s[a]||0,l=o[a]||0;if(f>l)return 1*i;if(l>f)return-1*i}return 0},r.prototype.compareTo=function(e){return this.compare(e)},r.prototype.compareAbs=function(e){return this.abs().compare(e.abs())},r.prototype.equals=function(e){return this.compare(e)===0},r.prototype.notEquals=function(e){return!this.equals(e)},r.prototype.lesser=function(e){return this.compare(e)<0},r.prototype.greater=function(e){return this.compare(e)>0},r.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},r.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},r.prototype.isPositive=function(){return this.sign===n.positive},r.prototype.isNegative=function(){return this.sign===n.negative},r.prototype.isEven=function(){return this.value[0]%2===0},r.prototype.isOdd=function(){return this.value[0]%2===1},r.prototype.isUnit=function(){return this.value.length===1&&this.value[0]===1},r.prototype.isDivisibleBy=function(e){return this.mod(e).equals(c)},r.prototype.isPrime=function(){var e=this.abs(),t=e.prev();if(e.isUnit())return!1;if(e.equals(2)||e.equals(3)||e.equals(5))return!0;if(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))return!1;if(e.lesser(25))return!0;var n=[2,3,5,7,11,13,17,19],r=t,i,s,o,u;while(r.isEven())r=r.divide(2);for(o=0;o<n.length;o++){u=bigInt(n[o]).modPow(r,e);if(u.equals(h)||u.equals(t))continue;for(s=!0,i=r;s&&i.lesser(t);i=i.multiply(2))u=u.square().mod(e),u.equals(t)&&(s=!1);if(s)return!1}return!0},r.prototype.toString=function(r){r===undefined&&(r=10);var i=this,s="",o=i.value.length;if(o===0)return"0";if(r===10)while(o--)i.value[o].toString().length===8?s+=i.value[o]:s+=(e.toString()+i.value[o]).slice(-t);else{var u=0,a=1,f=Math.floor(e/r);while(f>=a)u+=1,a*=r;var l=o+Math.floor((o-1)/u)+1,c=[],h=-1;while(++h<o)c[h]=i.value[h];var p=l;while(o!==0){var d=0,v=o;while(--v>=0){d=d*e+c[v];var m=Math.floor(d/a);c[v]=m,d-=m*a}while(o!==0&&c[o-1]===0)o-=1;p-=1,c[p]=d}s+=c[p].toString(r);while(++p<l){var g=c[p].toString(r),y=u-g.length;while(--y>=0)s+="0";s+=g}}while(s[0]==="0")s=s.slice(1);s.length||(s="0");if(s==="0")return s;var b=i.sign===n.positive?"":"-";return b+s},r.prototype.toJSNumber=function(){return+this.toString()},r.prototype.valueOf=function(){return this.toJSNumber()};var l=function(e,t){var e=new r(e,n.positive),t=new r(t,n.positive);if(e.equals(0))throw new Error("Cannot divide by 0");var i=0;do{var s=1,o=e,u=o.times(10);while(u.lesser(t))o=u,s*=10,u=u.times(10);while(o.lesserOrEquals(t))t=t.minus(o),i+=s}while(e.lesserOrEquals(t));return{remainder:t.value,result:i}},c=new r([0],n.positive),h=new r([1],n.positive),p=new r([1],n.negative),v=function(e,t){function o(e){var t=e[i].toLowerCase();if(i===0&&e[i]==="-"){s=!0;return}if(/[0-9]/.test(t))r.push(d(t));else if(/[a-z]/.test(t))r.push(d(t.charCodeAt(0)-87));else{if(t!=="<")throw new Error(t+" is not a valid character");var n=i;do i++;while(e[i]!==">");r.push(d(e.slice(n+1,i)))}}t=d(t);var n=c,r=[],i,s=!1;for(i=0;i<e.length;i++)o(e);r.reverse();for(i=0;i<r.length;i++)n=n.add(r[i].times(t.pow(i)));return s?n.negate():n},m=function(e,t){return typeof e=="undefined"?c:typeof t!="undefined"?v(e,t):d(e)};return m.zero=c,m.one=h,m.minusOne=p,m.randBetween=f,m.min=a,m.max=u,m.gcd=s,m.lcm=o,m}();typeof module!="undefined"&&(module.exports=bigInt);
"use strict";var bigInt=function(){function r(e,t){this.value=e,this.sign=t}function i(e){var t=[],n=0;for(var r=e.length-1;r>=0;r--){if(r>n&&e[r]===0)continue;n=r,t[r]=e[r]}return t}function s(e,t){return e=d(e).abs(),t=d(t).abs(),e.equals(t)?e:e.equals(c)?t:t.equals(c)?e:e.isEven()?t.isOdd()?s(e.divide(2),t):s(e.divide(2),t.divide(2)).multiply(2):t.isEven()?s(e,t.divide(2)):e.greater(t)?s(e.subtract(t).divide(2),t):s(t.subtract(e).divide(2),e)}function o(e,t){return e=d(e).abs(),t=d(t).abs(),e.multiply(t).divide(s(e,t))}function u(e,t){return e=d(e),t=d(t),e.greater(t)?e:t}function a(e,t){return e=d(e),t=d(t),e.lesser(t)?e:t}function f(t,n){t=d(t),n=d(n);var i=a(t,n),s=u(t,n),o=s.subtract(i),f=o.value.length-1,l=[],c=!0;for(var h=f;h>=0;h--){var p=c?o.value[h]:e,v=Math.floor(Math.random()*p);l.unshift(v),v<p&&(c=!1)}return i.add(new r(l,!1))}function d(i){if(i instanceof r)return i;if(Math.abs(+i)<e&&+i===(+i|0)){var s=+i;return new r([Math.abs(s)],s<0||1/s===-Infinity)}i+="";var o=n.positive,s=[];i[0]==="-"&&(o=n.negative,i=i.slice(1));var i=i.split(/e/i);if(i.length>2)throw new Error("Invalid integer: "+i.join("e"));if(i[1]){var u=i[1];u[0]==="+"&&(u=u.slice(1)),u=d(u);if(u.lesser(0))throw new Error("Cannot include negative exponent part for integers");while(u.notEquals(0))i[0]+="0",u=u.prev()}i=i[0],i==="-0"&&(i="0");var a=/^([0-9][0-9]*)$/.test(i);if(!a)throw new Error("Invalid integer: "+i);while(i.length){var f=i.length>t?i.length-t:0;s.push(+i.slice(f)),i=i.slice(0,f)}return new r(s,o)}function m(e){var t=e.value;return t.length===1&&t[0]<=36?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t[0]):"<"+t+">"}function g(e,t){t=bigInt(t);if(t.equals(0)){if(e.equals(0))return"0";throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1))return e.equals(0)?"0":e.lesser(0)?Array(1-e).join("10"):"1"+Array(+e).join("01");var n="";e.isNegative()&&t.isPositive()&&(n="-",e=e.abs());if(t.equals(1))return e.equals(0)?"0":n+Array(+e+1).join(1);var r=[],i=e,s;while(i.lesser(0)||i.compareAbs(t)>=0){s=i.divmod(t),i=s.quotient;var o=s.remainder;o.lesser(0)&&(o=t.minus(o).abs(),i=i.next()),r.push(m(o))}return r.push(m(i)),n+r.reverse().join("")}var e=1e7,t=7,n={positive:!1,negative:!0};r.prototype.negate=function(){return new r(this.value,!this.sign)},r.prototype.abs=function(){return new r(this.value,n.positive)},r.prototype.add=function(t){t=d(t);if(this.sign!==t.sign)return this.sign===n.positive?this.abs().subtract(t.abs()):t.abs().subtract(this.abs());var s=this.value,o=t.value,u=[],a=0,f=Math.max(s.length,o.length);for(var l=0;l<f||a>0;l++){var c=(s[l]||0)+(o[l]||0)+a;a=c>=e?1:0,c-=a*e,u.push(c)}return new r(i(u),this.sign)},r.prototype.plus=function(e){return this.add(e)},r.prototype.subtract=function(t){t=d(t);if(this.sign!==t.sign)return this.add(t.negate());if(this.sign===n.negative)return t.negate().subtract(this.negate());if(this.compare(t)<0)return t.subtract(this).negate();var s=this.value,o=t.value,u=[],a=0,f=Math.max(s.length,o.length);for(var l=0;l<f;l++){var c=s[l]||0,h=o[l]||0,p=c-a;a=p<h?1:0;var v=a*e+p-h;u.push(v)}return new r(i(u),n.positive)},r.prototype.minus=function(e){return this.subtract(e)},r.prototype.multiply=function(t){t=d(t);var n=this.sign!==t.sign,s=this.value,o=t.value,u=Math.max(s.length,o.length),a=[];for(var f=0;f<u;f++){a[f]=[];var l=f;while(l--)a[f].push(0)}var c=0;for(var f=0;f<s.length;f++){var h=s[f];for(var l=0;l<o.length||c>0;l++){var p=o[l],v=p?h*p+c:c;c=v>e?Math.floor(v/e):0,v-=c*e,a[f].push(v)}}var m=-1;for(var f=0;f<a.length;f++){var g=a[f].length;g>m&&(m=g)}var y=[],c=0;for(var f=0;f<m||c>0;f++){var b=c;for(var l=0;l<a.length;l++)b+=a[l][f]||0;c=b>e?Math.floor(b/e):0,b-=c*e,y.push(b)}return new r(i(y),n)},r.prototype.times=function(e){return this.multiply(e)},r.prototype.divmod=function(e){e=d(e);var t=this.sign!==e.sign;if(this.equals(0))return{quotient:new r([0],n.positive),remainder:new r([0],n.positive)};if(e.equals(0))throw new Error("Cannot divide by zero");var s=this.value,o=e.value,u=[],a=[];for(var f=s.length-1;f>=0;f--){var c=[s[f]].concat(a),h=l(o,c);u.push(h.result),a=h.remainder}return u.reverse(),{quotient:new r(i(u),t),remainder:new r(i(a),this.sign)}},r.prototype.divide=function(e){return this.divmod(e).quotient},r.prototype.over=function(e){return this.divide(e)},r.prototype.mod=function(e){return this.divmod(e).remainder},r.prototype.remainder=function(e){return this.mod(e)},r.prototype.pow=function(e){e=d(e);var t=this,n=e,r=h;if(n.equals(c))return r;if(t.equals(c)||n.lesser(c))return c;for(;;){n.isOdd()&&(r=r.times(t)),n=n.divide(2);if(n.equals(c))break;t=t.times(t)}return r},r.prototype.modPow=function(e,t){e=d(e),t=d(t);if(t.equals(c))throw new Error("Cannot take modPow with modulus 0");var n=h,r=this.mod(t);if(r.equals(c))return c;while(e.greater(0))e.isOdd()&&(n=n.multiply(r).mod(t)),e=e.divide(2),r=r.square().mod(t);return n},r.prototype.square=function(){return this.multiply(this)},r.prototype.next=function(){return this.add(1)},r.prototype.prev=function(){return this.subtract(1)},r.prototype.compare=function(e){var t=this,r=d(e);if(t.value.length===1&&r.value.length===1&&t.value[0]===0&&r.value[0]===0)return 0;if(r.sign!==t.sign)return t.sign===n.positive?1:-1;var i=t.sign===n.positive?1:-1,s=t.value,o=r.value,u=Math.max(s.length,o.length)-1;for(var a=u;a>=0;a--){var f=s[a]||0,l=o[a]||0;if(f>l)return 1*i;if(l>f)return-1*i}return 0},r.prototype.compareTo=function(e){return this.compare(e)},r.prototype.compareAbs=function(e){return this.abs().compare(e.abs())},r.prototype.equals=function(e){return this.compare(e)===0},r.prototype.notEquals=function(e){return!this.equals(e)},r.prototype.lesser=function(e){return this.compare(e)<0},r.prototype.greater=function(e){return this.compare(e)>0},r.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},r.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},r.prototype.isPositive=function(){return this.sign===n.positive},r.prototype.isNegative=function(){return this.sign===n.negative},r.prototype.isEven=function(){return this.value[0]%2===0},r.prototype.isOdd=function(){return this.value[0]%2===1},r.prototype.isUnit=function(){return this.value.length===1&&this.value[0]===1},r.prototype.isDivisibleBy=function(e){return this.mod(e).equals(c)},r.prototype.isPrime=function(){var e=this.abs(),t=e.prev();if(e.isUnit())return!1;if(e.equals(2)||e.equals(3)||e.equals(5))return!0;if(e.isEven()||e.isDivisibleBy(3)||e.isDivisibleBy(5))return!1;if(e.lesser(25))return!0;var n=[2,3,5,7,11,13,17,19],r=t,i,s,o,u;while(r.isEven())r=r.divide(2);for(o=0;o<n.length;o++){u=bigInt(n[o]).modPow(r,e);if(u.equals(h)||u.equals(t))continue;for(s=!0,i=r;s&&i.lesser(t);i=i.multiply(2))u=u.square().mod(e),u.equals(t)&&(s=!1);if(s)return!1}return!0},r.prototype.toString=function(r){r===undefined&&(r=10);if(r!==10)return g(this,r);var i=this,s="",o=i.value.length;if(o===0)return"0";while(o--)i.value[o].toString().length===8?s+=i.value[o]:s+=(e.toString()+i.value[o]).slice(-t);while(s[0]==="0")s=s.slice(1);s.length||(s="0");if(s==="0")return s;var u=i.sign===n.positive?"":"-";return u+s},r.prototype.toJSNumber=function(){return+this.toString()},r.prototype.valueOf=function(){return this.toJSNumber()};var l=function(e,t){var e=new r(e,n.positive),t=new r(t,n.positive);if(e.equals(0))throw new Error("Cannot divide by 0");var i=0;do{var s=1,o=e,u=o.times(10);while(u.lesser(t))o=u,s*=10,u=u.times(10);while(o.lesserOrEquals(t))t=t.minus(o),i+=s}while(e.lesserOrEquals(t));return{remainder:t.value,result:i}},c=new r([0],n.positive),h=new r([1],n.positive),p=new r([1],n.negative),v=function(e,t){function o(e){var t=e[i].toLowerCase();if(i===0&&e[i]==="-"){s=!0;return}if(/[0-9]/.test(t))r.push(d(t));else if(/[a-z]/.test(t))r.push(d(t.charCodeAt(0)-87));else{if(t!=="<")throw new Error(t+" is not a valid character");var n=i;do i++;while(e[i]!==">");r.push(d(e.slice(n+1,i)))}}t=d(t);var n=c,r=[],i,s=!1;for(i=0;i<e.length;i++)o(e);r.reverse();for(i=0;i<r.length;i++)n=n.add(r[i].times(t.pow(i)));return s?n.negate():n},y=function(e,t){return typeof e=="undefined"?c:typeof t!="undefined"?v(e,t):d(e)};return y.zero=c,y.one=h,y.minusOne=p,y.randBetween=f,y.min=a,y.max=u,y.gcd=s,y.lcm=o,y}();typeof module!="undefined"&&(module.exports=bigInt);

@@ -147,5 +147,8 @@ /// <reference path="BigInteger.js" />

"(0/1) + -100 = -100": (bigInt("0")).divide(bigInt("1")).add(bigInt("-100")).toString() === "-100", // see pull request 16
"dec 366900685503779409298642816707647664013657589336 = hex 4044654fce69424a651af2825b37124c25094658": bigInt("366900685503779409298642816707647664013657589336").toString(16) === "4044654fce69424a651af2825b37124c25094658"
"dec 366900685503779409298642816707647664013657589336 = hex 4044654fce69424a651af2825b37124c25094658": bigInt("366900685503779409298642816707647664013657589336").toString(16) === "4044654fce69424a651af2825b37124c25094658",
"secretmessage000 converts to and from base -36": bigInt("secretmessage000", -36).toString(-36) === "secretmessage000",
"-256 == -100 base 16": bigInt(-256).toString(16) === "-100",
"256 in base 1 has 256 ones": bigInt(256).toString(1).length === 256
});
return assertions.join("<br>");
})(bigInt);
{
"name": "big-integer",
"version": "1.3.16",
"version": "1.3.17",
"author": "Peter Olson <peter.e.c.olson+npm@gmail.com>",

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

@@ -326,6 +326,24 @@ BigInteger.js

---
Converts a bigInt to a string. There is an optional radix parameter (which defaults to 10) that converts the number to the given radix. Only integer radixes from 2 to 26 are permitted.
Converts a bigInt to a string. There is an optional radix parameter (which defaults to 10) that converts the number to the given radix. Digits in the range `10-36` will use the letters `a-z`.
- `bigInt("1e9").toString()` => `"1000000000"`
- `bigInt("1e9").toString(16)` => `"3b9aca00"`
Bases larger than 36 are supported. If a digit is larger than 36, it will be enclosed in angle brackets.
- `bigInt(567890).toString(100)` => `"<56><78><90>"`
Negative bases are also supported.
- `bigInt(12345).toString(-10)` => `"28465"`
Base 1 and base -1 are also supported.
- `bigInt(-15).toString(1)` => `"-111111111111111"`
- `bigInt(-15).toString(-1)` => `"101010101010101010101010101010"`
Base 0 is only allowed for the number zero.
- `bigInt(0).toString(0)` => `0`
- `bigInt(1).toString(0)` => `Error: Cannot convert nonzero numbers to base 0.`

@@ -332,0 +350,0 @@ `valueOf()`

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