Skip to content
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

Typo in Number.prototype.toExponential #2449

Closed
jorendorff opened this issue Jul 5, 2021 · 0 comments · Fixed by #2450
Closed

Typo in Number.prototype.toExponential #2449

jorendorff opened this issue Jul 5, 2021 · 0 comments · Fixed by #2450

Comments

@jorendorff
Copy link
Contributor

jorendorff commented Jul 5, 2021

https://tc39.es/ecma262/#sec-number.prototype.toexponential

step 10.a.i reads:

  1. Let e and n be integers such that 10fn < 10f + 1 and for which n × 10e - n - x is as close to zero as possible. If there are two such sets of e and n, pick the e and n for which n × 10e - f is larger.

This can't be right.

Example: Suppose x, the number we're trying to format, is 123, and f = fractionDigits = 2. The correct output would be "1.23e2", which happens if this step selects n = 123 and e = 2. But the method described above selects n = 123 and e = 125.

It seems to be a typo introduced in #1135. _n_ &times; 10<sup>_e_ - _n_</sup> - _x_ should be changed back to _n_ &times; 10<sup>_e_ - _f_</sup> - _x_.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant