From e631d629d0806040c7fb32b51ad01ae64d606adf Mon Sep 17 00:00:00 2001 From: Austin Date: Tue, 9 Apr 2019 00:14:42 -0700 Subject: [PATCH] Improve .toString(2) performance --- BigInteger.js | 1 + 1 file changed, 1 insertion(+) diff --git a/BigInteger.js b/BigInteger.js index c5eb715..848bd66 100644 --- a/BigInteger.js +++ b/BigInteger.js @@ -1314,6 +1314,7 @@ var bigInt = (function (undefined) { BigInteger.prototype.toString = function (radix, alphabet) { if (radix === undefined) radix = 10; + if (radix === 2) 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) {