Commit f611ea7
committed
Make rounding more consistent
When formatting a value like 7.897 with a precision of 2 digits the code
was:
* muliplying the value by 100 (10^precision) => 789.7;
* rouding the value => 790;
* dividing the value by 100 => 7.9
This is inconsistent with other float values displayed with 2 decimal
digits. Prefer the toFixed method which returns a string, "7.90" in the
above exapmle.
Since we also have integer values, and because JS is a joke that only
knows about floats, attempt to guess if the value is an integer and do
not display decimals in this case to keep the previous behavor in this
case.1 parent 494f89d commit f611ea7
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
10 | 14 | | |
11 | 15 | | |
12 | 16 | | |
| |||
0 commit comments