May 10, 2012

Javascript round() Method

function roundNumber(num, dec) {
 var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
 return result;
}

and then write code something like this :
roundNumber(dec_number,2)

As simple as that!


Cheers..

No comments:

Post a Comment