Skip to content

Conversation

@eemeli
Copy link
Member

@eemeli eemeli commented Oct 29, 2025

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 introduce ZeroDigits as 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, as style: 'percent' can be combined with notation: 'engineering' or notation: 'scientific'.

Ping @sffc, @gibson042, @jessealama, @ben-allen for reviews.

1. If _x_ is not ~negative-zero~, then
1. Assert: _x_ is a mathematical value.
1. If _numberFormat_.[[Style]] is *"percent"*, set _x_ be 100 × _x_.
1. <ins>Let _magnitude_ be the base 10 logarithm of abs(_x_) rounded down to the nearest integer.</ins>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Priority Issues

Development

Successfully merging this pull request may close these issues.

3 participants