0
Hi pals, if you divide a number and the answer has many number of decimal places, how can you declare specific# of decimal place
Example var x= 1 ; var y=3; var z=x/y; alert (z) ; Output is 0.333333333333 Me I want to declare an answer into 2 or 3 decimal places. Can anyone help me.
4 Answers
+ 2
alert(z.toFixed(2));
+ 1
Thanks a lot
0
If you don't like the 6.00 type display, use:
z = Math.trunc(z*100)/100;