round number 2 decimal places javascript

54

javascript round decimal 2 digits -

var numb = 123.23454;
numb = numb.toFixed(2);

round number 2 decimal places javascript -

function roundTo2(num) {
  return Math.round( ( num + Number.EPSILON ) * 100 ) / 100;
}

javascript round decimal -

Number((6.688689).toFixed(2)); // 6.69

javascript round to 8 decimal places -

>>> parseFloat(0.9999999.toFixed(4));
1
>>> parseFloat(0.0009999999.toFixed(4));
0.001
>>> parseFloat(0.0000009999999.toFixed(4));
0

Comments

Submit
0 Comments