Skip to content

Never use exponential if radix not 10 (Fix #3739, #3740) - #3742

Merged
chakrabot merged 1 commit into
chakra-core:release/1.7from
xiaoyinl:never_use_exp
Oct 21, 2017
Merged

chakrabot merged 1 commit into
chakra-core:release/1.7from
xiaoyinl:never_use_exp

Conversation

@xiaoyinl

@xiaoyinl xiaoyinl commented Sep 15, 2017 •

Copy link
Copy Markdown
Contributor

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

@xiaoyinl
xiaoyinl changed the base branch from master to release/1.7 September 15, 2017 06:49

@dilijev dilijev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'll let others weigh in about the behavior change.

Comment thread test/Number/toString.js Outdated
runTest('new Number(-444123.78963636363636363636)');
runTest('new Number(0)');
runTest('1e21');
runTest('1.1e21');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe also add tests for 1e21+1 and 1e21-1 (integers one before and after the boundary) and compare output with other engines. Maybe 1e21+0.1 and 1e21-0.1 also?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These numbers all equal to 1e21 due to the loss of precision. How about adding 0.9999999999999999e21 and 1.0000000000000001e21?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, that sounds good. :)

@xiaoyinl

Copy link
Copy Markdown
Contributor Author

@dotnet-bot test Ubuntu static_ubuntu_linux_test please

@jackhorton

Copy link
Copy Markdown
Contributor

Any updates on this? I believe it is blocking nodejs/node-chakracore#390.

…#3740)

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 #3740.

Related issues: #2751, #3635.
@MikeHolman

Copy link
Copy Markdown
Contributor

So just for fun I did some archeology to see why we are doing this, and turns out this code goes all the way back to at least 2002 (when it was copied between source trees). I don't think anyone has considered this behavior in a very long time.

Seems to me like a fine change to get compat with the other browsers.

@dilijev

dilijev commented Oct 18, 2017

Copy link
Copy Markdown
Contributor

@MikeHolman can you adopt and merge this PR?

@dilijev dilijev assigned dilijev and unassigned MikeHolman Oct 18, 2017

@dilijev dilijev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@dilijev

dilijev commented Oct 18, 2017

Copy link
Copy Markdown
Contributor

Spoke with @MikeHolman - I'll test this one internally and then merge it.

@dilijev
dilijev changed the base branch from release/1.7 to master October 18, 2017 23:15
@dilijev
dilijev changed the base branch from master to release/1.7 October 18, 2017 23:16
@dilijev

dilijev commented Oct 18, 2017

Copy link
Copy Markdown
Contributor

Note: merging to release/1.7 to unblock the node-chakracore scenario: #3742 (comment)

@chakrabot
chakrabot merged commit 4c8fc73 into chakra-core:release/1.7 Oct 21, 2017
chakrabot pushed a commit that referenced this pull request Oct 21, 2017
, #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
chakrabot pushed a commit that referenced this pull request Oct 21, 2017
…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
@xiaoyinl
xiaoyinl deleted the never_use_exp branch March 29, 2018 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants