xxxxxxxxxx
var subTotal="12.1345";// can also be int, float, string
var subTotalFormatted=parseFloat(subTotal).toFixed(2); //"12.13"
xxxxxxxxxx
var subTotal="12.1345";// can also be int, float, string
var subTotalFormatted=parseFloat(subTotal).toFixed(2); //"12.13"
xxxxxxxxxx
function roundTo2(num) {
return Math.round( ( num + Number.EPSILON ) * 100 ) / 100;
}
xxxxxxxxxx
>>> parseFloat(0.9999999.toFixed(4));
1
>>> parseFloat(0.0009999999.toFixed(4));
0.001
>>> parseFloat(0.0000009999999.toFixed(4));
0
xxxxxxxxxx
var num = 0,19784342446461994;
num = num.toFixed(5); // get total 5 number => 0,19784
num = num.toFixed(6); // get total 6 number => 0,197843
num = num.toFixed(7); // get total 7 number => 0,1978434