Posted By

dato on 12/13/11


Tagged

javascriptdecimalnumberMath


Versions (?)

Round to certain decimal points


 / Published in: JavaScript
 

Rounds a number to a given decimal quantity

  1. function roundNumber(numero, dec) {
  2. var num=parseFloat(numero);
  3. var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
  4. return result;
  5. }

Report this snippet  

You need to login to post a comment.