I have a float numbers like : 0.24405750549007688
I would like to convert it to -> 0.2441
How can i do it with jquery ?
I have a float numbers like : 0.24405750549007688
I would like to convert it to -> 0.2441
How can i do it with jquery ?
Try using bellow
(6.688689).toFixed(); // equal to 7
(6.688689).toFixed(1); // equal to 6.7
(6.688689).toFixed(2); // equal to 6.69
0.24405750549007688.toFixed(4)
"0.2441" <-- string
parseFloat(0.24405750549007688.toFixed(4))
0.2441 <-- number
var myFourDigit = (0.24405750549007688).toFixed(4) // will output 0.2440
not efficient but it will do the trick:
var n=0.24405750549007688
n*=10000;
n=Math.round(n)/10000;
console.log(n);