-
Notifications
You must be signed in to change notification settings - Fork 1
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
Implement Number.prototype.toFixed()
#35
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good, I added some comments :)
After a lot of testing this is ready for review/merge 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can see this look good. I'm not gonna pretend I understand all of the math behind this, but the code looks understandable to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Just added some missing newlines that I'll commit with the reviews.
Oh, we didn't configure the queue for this repo. Let me open a PR for it. |
556e328
to
e7e7d77
Compare
This Pull Request fixes/closes #32.
This PR implements a WIP implementation of
Number.prototype.toFixed()
. This is a port of the official https://github.com/ulfjack/ryu/ repository'sprintf %f
implementation, modified to comply to theNumber.prototype.toFixed()
behaviour.Changes:
Number.prototype.toFixed()
TODO:
Buffer
size.Partially generate them, and compute some at runtime.The tables after shrinking them down with the method below. I think they are small enough now, I think Ill leave this for alter implementing other float to string conversions ImplementNumber.prototype.toExponential()
#31 and ImplementNumber.prototype.toPrecision()
#331e21
uses the default format and precision is clamped[0, 100]
. We might be able to trim it.POW10_SPLIT
from1224
to8
(29184
bytes)~99.35%
reductionPOW10_SPLIT_2
from3133
to481
(63648
bytes)~84.65%
reduction