-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
1e+19.toString(2)
is displayed exponentially, but should be written out
#2751
Comments
@littledan Section 20.1.3.6 says if the radix is not 10, "the precise algorithm is implementation-dependent", but it should be a generalization of 7.1.12.1. I wonder how it's generalized. For example, it seems v8 and SpiderMonkey never use exponential notation when the radix isn't 10, even though the base 10 exponent is larger than 21, like this:
Should Chakra match this behavior too? |
@xiaoyinl It seems that SpiderMonkey, JSC and V8 all agree that it should be generalized in a way that never switches to exponential notation. If ChakraCore wants to have similar behavior to other engines, it could adopt that same behavior. If the specification more specifically documented the 3/4 behavior, would that help ChakraCore? cc @bterlson |
@littledan any improvements to the spec in terms of reflecting reality is very helpful :) |
…ponentially (Fixes #2751) Merge pull request #3635 from xiaoyinl:num_exp The spec section 7.1.12.1 requires that if a number's base 10 logarithm is <= 21, then it shouldn't use exponential notation when it's converted to String. The original code checks if the base 2 logarithm of the number is <= 60. This fixes #2751.
… displayed exponentially (Fixes #2751) Merge pull request #3635 from xiaoyinl:num_exp The spec section 7.1.12.1 requires that if a number's base 10 logarithm is <= 21, then it shouldn't use exponential notation when it's converted to String. The original code checks if the base 2 logarithm of the number is <= 60. This fixes #2751.
, #3740) Merge pull request #3742 from xiaoyinl:never_use_exp Other engines (SpiderMonkey, JSC and V8) never use exponential display for num.toString(radix) if radix is not 10, no matter how large num is. This PR updates the code and the test cases to match that behavior. This PR fixes #3739 and fixes #3740. See also: #2751, #3635. /cc @dilijev @littledan @bterlson
…ot 10 (Fix #3739, #3740) Merge pull request #3742 from xiaoyinl:never_use_exp Other engines (SpiderMonkey, JSC and V8) never use exponential display for num.toString(radix) if radix is not 10, no matter how large num is. This PR updates the code and the test cases to match that behavior. This PR fixes #3739 and fixes #3740. See also: #2751, #3635. /cc @dilijev @littledan @bterlson
The output given by ChakraCore is
1.00010101100011100100011000001001000100111101(e+63)
, but in three other engines, the correct answer of1000101011000111001000110000010010001001111010000000000000000000
is provided. The spec states that with n (the base-10 exponent) between 0 and 21, the written out version should be used, rather than the exponential version.The text was updated successfully, but these errors were encountered: