0
<script>

var c28 = 15;
var c10 = 3;
var c12 = Math.round((((c28-c10)/9)+parseFloat(c10)),1);
alert(c12);
</script>

Before the round, output was 4.3333333. I want output as 4.3 after round. but it is showing 4 only. Decimal part is not showing. Please help.

  • multiply by 10 ....round...divide by 10 – charlietfl Jul 11 '17 at 19:13
  • `Math.round` doesn't take a precision parameter. May be you indeed want `x.toFixed(1)` that given a number `x` will display its approximation to the specified number of decimals. – 6502 Jul 11 '17 at 19:16
  • I think you will find the answer [here](https://stackoverflow.com/questions/11832914/round-to-at-most-2-decimal-places-only-if-necessary), just substitute "1" for "2" in all the solutions. – abalter Jul 11 '17 at 19:17

0 Answers0