Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve .toString(2) performance #178

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Azero123
Copy link

@Azero123 Azero123 commented Apr 9, 2019

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 94.223% when pulling e631d62 on Azero123:master into 2e06193 on peterolson:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 94.223% when pulling e631d62 on Azero123:master into 2e06193 on peterolson:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.006%) to 94.223% when pulling e631d62 on Azero123:master into 2e06193 on peterolson:master.

@coveralls
Copy link

coveralls commented Apr 9, 2019

Coverage Status

Coverage increased (+0.006%) to 94.223% when pulling b22ebb6 on Azero123:master into 2e06193 on peterolson:master.

BigInteger.js Outdated
@@ -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('');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about the alphabet argument?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes i did not consider that. I updated it to only apply the optimization if the alphabet parameter is not provided. That may be a bit hacky now, whatcha think?

@peterolson
Copy link
Owner

Good point @Yaffle, that makes me realize that the alphabet argument isn't working for base 10 either. I should add more tests for the toString method with the alphabet argument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants