# Fix the rounding issue #2027

Open
wants to merge 1 commit into
from
+2 −2

## Conversation

Projects
None yet
3 participants
Contributor

### FrankYFTang commented Jan 9, 2019

 No description provided.
``` Fix the rounding issue ```
``` 2dcce56 ```
Contributor

### sffc commented Jan 9, 2019

 The spec says to use half-up rounding for both fraction and scientific. https://www.ecma-international.org/ecma-402/5.0/index.html#sec-torawprecision Let e and n be integers such that 10p–1 ≤ n < 10p and for which the exact mathematical value of n × 10e–p+1 – 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–p+1 is larger. and https://www.ecma-international.org/ecma-402/5.0/index.html#sec-torawfixed Let n be an integer for which the exact mathematical value of n ÷ 10f – x is as close to zero as possible. If there are two such n, pick the larger n. In both cases, if there is a tie, pick the "larger" one. This part of the spec operates only on positive numbers, so this means to round away from zero.

### ljharb reviewed Jan 9, 2019

 @@ -23,8 +23,8 @@ var numberingSystems = [ ]; var testData = { // Ref tc39/ecma402#128

#### ljharb Jan 9, 2019

Member

this comment links to the still-open issue: tc39/ecma402#128 - are we confident about the conclusion both there and here?

Open

### sffc commented Jan 9, 2019

 I've commented before on tc39/ecma402#128, and the current web reality, which is consistent with my interpretation of the spec, is that rounding behavior in the spec should not be influenced by floating-point noise. `(123.445).toLocaleString("en", {maximumFractionDigits:2}) // 123.45 in Chrome and Firefox` I also found the PR that added the current test262 behavior: #857 It does make sense to resolve tc39/ecma402#128 first, and then update test262.