From b22ebb65791daf02dda79d40862da3882fba0049 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..958bf89 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 && !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) {