-
-
Notifications
You must be signed in to change notification settings - Fork 401
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
Feature/number object #182
Conversation
6d82f34
to
895b974
Compare
Apart from that this is looking good, @pop |
12d81c9
to
439491a
Compare
I will play with toPrecision() and im not sure what we do about locale at this point |
That should have been handled here: |
@jasonwilliams Strange. I'll try to play around with it more. I may be consuming numbers incorrectly. |
I did some tests and I think the parsing for the scientific notation is a bit off: Number(3e12) // Passes
Number(-3e-12) // Fails
Number(3e-12) // Passes
Number(-3e-12) // Fails
Number(3.34e12) // Fails
Number(3.45e-12) // Fails
Number(-3.45e-12) // Fails All of these work in The failures in
The tests you linked to only include scientific notation numbers of the form I still think that fixing this is out of scope for this issue. Thoughts? I'd love to see this merged, but I'm willing to make more changes 😅 |
Just checked out your branch let a = Number(-3e12);
a; seems to work fine for me |
I think the best situation would be to make an issue with the scientific notation that fails and we can fix those there. |
Includes: - make_number() - call_number() - Number().toExponential() - Number().toFixed() - Number().toLocaleString() (ish) - Number().toString() - Number().valueOf() - create_constructor() - init() Missing: - Number().toPrecision() refs boa-dev#34
I don't have all the context on _why_ but all of the tests for `Number` started failing. Upon investigation it was becuase `const` stopped acting the way I expected. Switching my test cases from using `const` to using `var` variable declarations made everything work again. I don't know enough about JS to know if this is a bug or expected behavior. Based on changes to other tests, it is know behavior. Refs boa-dev#34
Includes some clippy fixes. Fixes boa-dev#34
439491a
to
1796146
Compare
@jasonwilliams I narrowed it down to floats in scientific notation not parsing correctly, so my |
This looks good, im glad you raised an issue we can fix that separately. |
Hey @jasonwilliams. This isn't quite done yet but I would love to get your feedback.
I have most of Number() working (I think) with a few exceptions:
toPrecision()
is not done. It's a tough function to write and I haven't figured out how to write it.toLocaleString()
is not great.We also have a problem where trying to parse something like
Number(0.00)
andNumber(1e+5)
fail. I think this is beyond the scope of the project. My workaround is to parse those cases as strings:Number("1e+5")
works as expected.Let me know if I should make changes to my tests or implementations, or if you have thoughts about the
toLocaleString
andtoPrecision
functions.