-
Notifications
You must be signed in to change notification settings - Fork 1
Fix corner-case issues identified in testing #10
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
base: main
Are you sure you want to change the base?
Conversation
|
This PR was discussed at the recent TC39 plenary, and concluded with support for merging this, once it's been reviewed by @sffc and/or @gibson042. |
|
With style percent, it should format as 6.50%, yes? So I don't see why we need to adjust stringDigitCount in style percent. I also don't understand why you say that |
No, its string digit count is 5.
Yes.
That is required because when multiplying by 100 for formatting the leading zeros need to be dropped.
It's not possible for us to always determine the significant digit count, for example for a value like |
While putting together tc39/test262#4608, I validated the proposed spec text with a patched fork of FormatJS, and this identified a few places where the spec text needs to be updated:
Leading zeros need to be discarded, so we count
'0012.3'to have three string digits. To do so in the syntax-directed operation, I introduceZeroDigitsas a new syntax rule.An elided leading zero needs to be accounted for, so
'.45'should count as having three string digits.Changes in exponents that reduce the number of leading zeros need to also reduce the string digit count accordingly. This means that when formatted as a percentage,
'0.06'should format as if it had only one string digit, rather than three. This adjustment needs to be done potentially twice, asstyle: 'percent'can be combined withnotation: 'engineering'ornotation: 'scientific'.Ping @sffc, @gibson042, @jessealama, @ben-allen for reviews.