Created
July 11, 2012 19:17
-
-
Save james2doyle/3092545 to your computer and use it in GitHub Desktop.
Round a number to a set amount of decimal places
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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