Skip to content

Commit

Permalink
Improve .toString(2) performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Azero123 committed Apr 10, 2019
1 parent 2e06193 commit b22ebb6
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions BigInteger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,7 @@ var bigInt = (function (undefined) {

BigInteger.prototype.toString = function (radix, alphabet) {
if (radix === undefined) radix = 10;
if (radix === 2 && !alphabet) return (this.sign ? "-" : "") + this.toArray(2).value.join('');
if (radix !== 10) return toBaseString(this, radix, alphabet);
var v = this.value, l = v.length, str = String(v[--l]), zeros = "0000000", digit;
while (--l >= 0) {
Expand Down

0 comments on commit b22ebb6

Please sign in to comment.