Skip to content

Instantly share code, notes, and snippets.

@james2doyle
Created July 11, 2012 19:17
Show Gist options
  • Save james2doyle/3092545 to your computer and use it in GitHub Desktop.
Save james2doyle/3092545 to your computer and use it in GitHub Desktop.
Round a number to a set amount of decimal places
function roundNumber(num, dec) {
var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment