-
Notifications
You must be signed in to change notification settings - Fork 741
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
Custom ALPHABET ignored for base 10 #250
Comments
Yes. The problem is that I want to keep BigNumber creation as fast as possible when a base argument of 10 is passed to the constructor, because many users include it as a matter of course. Currently, a time-consuming base conversion is avoided (and exponential notation is also accepted) using // Allow exponential notation to be used with base 10 argument, while
// also rounding to DECIMAL_PLACES as with other bases.
if (b == 10) {
x = new BigNumber(v);
return round(x, DECIMAL_PLACES + x.e + 1, ROUNDING_MODE);
} Yes, I could change that to if (b == 10 && ALPHABET.slice(0, 10) === '0123456789') { but I don't want to add further code to a very hot path in the constructor just to cover a case which nobody probably uses. I may just make it explicit in the documentation that that first 10 characters of the alphabet are hard-coded to |
Could it do this check once when a new Just adding it to the documentation would work OK as well. On the other hand, since it is possible to opt out by not specifying the base, wouldn't it be better to fix it and document the performance implications instead? |
Yes, I'll consider it. |
Fixed in v9.0.2. Thanks for your input. |
ALPHABET
appears to be hardcoded to'0123456789'
when the base is 10.Log:
The text was updated successfully, but these errors were encountered: