Round to certain decimal points


/ Published in: JavaScript
Save to your folder(s)

Rounds a number to a given decimal quantity


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.