The formula is a bit long but works:
1 2 3 4 5 6 7 | function round(x) { return parseFloat(Math.round(x * 10) / 10).toFixed(1).replace(/\.0/, "" ) } round(458.21456); // -> 458.2 round(500); // -> 500 round(603.18); // -> 603.2 |
The formula is a bit long but works:
1 2 3 4 5 6 7 | function round(x) { return parseFloat(Math.round(x * 10) / 10).toFixed(1).replace(/\.0/, "" ) } round(458.21456); // -> 458.2 round(500); // -> 500 round(603.18); // -> 603.2 |