Skip to content

Commit e631d62

Browse files
committed
Improve .toString(2) performance
1 parent 2e06193 commit e631d62

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

BigInteger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,7 @@ var bigInt = (function (undefined) {
13141314

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

0 commit comments

Comments
 (0)