-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add Decimal128 to Intl.NumberFormat #104
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.
Overall 402 parts LGTM, note that you would also have to tweak the NumberFormat functions to accept the Decimals and pass them down to ToIntlMathematicalValue for this to work.
AFAICS it's enough to tweak |
@sffc How does this look? AFAICS the relevant |
This function makes
|
I took another look and found out what I was missing. Indeed, as @ryzokuken also said, it's not enough to extend the definition of Intl mathematical value. I've now tweaked the definitions of the various format functions to accept decimals. AFAICS, we should now be able to handle the initial motivating example. (At least, that's my intent.) Are we getting there? |
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.
^
Set up the algorithm to work with both mathematical values and Decimal128 objects by initializing relevant variables to `undefined` straight away, and set their values depending on the type of the argument of the abstract operation.
Also, remove `Call`, use of `[[accessor]]`, and so on.
I'll want to give this another pass when the proposal goes up for stage 2.7. |
It looks like you made |
Might it be possible to replace Intl mathematical values altogether with Decimal128 values? |
This may have worked before NFv3 but at this point it would probably break the web since Intl.NumberFormat allows higher precision than Decimal128 |
I think the best we can do is to bolt Decimal128 values onto Intl mathematical values (done in #163), handle them as-is (that is, without canonicalization/normalization) as far as possible, and then impute additional data (e.g., trailing zeroes) in case an Intl AO demands more than what Decimal128 can provide. |
The intention here is to make Decimal128 objects valid inputs to the various
Intl.NumberFormat
functions. One of the guiding examples is thatnew Intl.NumberFormat("de-DE").format(new Decimal128("-42.0"))
should produce "42,0". AFAICS, it's enough to add support for Decimal128 in theToIntlMathematicalValue
abstract operation, but if I'm overlooking something, please let me know!