Home
Analytics
Round to 2 decimal places
Raj_t
Hi
I am having issues with rounding a number. I am unable to round a number to (for example) the 2nd decimal......10.666666should be 10.67
I found Math.round but it gives me the nearest integer....11
Please help me in solving this.
Thanks,
Raj.
Find more posts tagged with
Comments
Dragunov
did you try like this
Math.round(val*Math.pow(10,dec))/Math.pow(10,dec)
where "dec" is the for precision ie. the number of decimal places you want and "val" is the original decimal value .
Raj_t
Thanks very much. That solution worked out for me.