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

Fix Number.toExponential and Number.toFixed #1602

Closed
raskad opened this issue Sep 29, 2021 · 3 comments · Fixed by #1620
Closed

Fix Number.toExponential and Number.toFixed #1602

raskad opened this issue Sep 29, 2021 · 3 comments · Fixed by #1620
Assignees
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics E-Easy Easy good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Milestone

Comments

@raskad
Copy link
Member

raskad commented Sep 29, 2021

The functions toExponential and toFixed of the Number prototype are currently not implemented spec compliant. All of the tests for those two functions should pass if they do not rely on other features that are not implemented.

To see the exact failed tests, take a look at the current results at https://boa-dev.github.io/boa/test262/

Spec references:

@raskad raskad added bug Something isn't working good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com E-Easy Easy builtins PRs and Issues related to builtins/intrinsics labels Sep 29, 2021
@nrabulinski
Copy link
Contributor

Hi, I'd like to work on this issue! I've gotten all but exactness.js from toFixed to pass, but it seems like calling as_number on 1000000000000000128 actually returns 1000000000000000000.0, is this a known issue? The toString part of that test is also failing because of that.

@jedel1043
Copy link
Member

jedel1043 commented Oct 1, 2021

Hi, I'd like to work on this issue! I've gotten all but exactness.js from toFixed to pass, but it seems like calling as_number on 1000000000000000128 actually returns 1000000000000000000.0, is this a known issue? The toString part of that test is also failing because of that.

I think that's because Javascript only supports i32 integers, so any number that exceeds i32::MAX is automatically converted to an f64. However, 1000000000000000128 is not representable with an f64, so it should return 1000000000000000100 instead.

@nrabulinski
Copy link
Contributor

Hi, I'd like to work on this issue! I've gotten all but exactness.js from toFixed to pass, but it seems like calling as_number on 1000000000000000128 actually returns 1000000000000000000.0, is this a known issue? The toString part of that test is also failing because of that.

I think that's because Javascript only supports i32 integers, so any number that exceeds i32::MAX is automatically converted to an f64. However, 1000000000000000128 is not representable with an f64, so it should return 1000000000000000100 instead.

Yes, it should and that's how toString is defined (it should round to 1000000000000000100). I'll investigate further later :)

@Razican Razican added this to the v0.14.0 milestone Feb 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working builtins PRs and Issues related to builtins/intrinsics E-Easy Easy good first issue Good for newcomers Hacktoberfest Hacktoberfest 2021 - https://hacktoberfest.digitalocean.com
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants