Last active
August 29, 2015 14:01
-
-
Save mattlundstrom/3b9fa5cd671c23c82904 to your computer and use it in GitHub Desktop.
Rounding
This file contains hidden or 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 roundToDecimal( number, decimalPlaces ){ | |
var multiplier = Math.pow( 10, decimalPlaces ); | |
return Math.round( number * multiplier ) / multiplier; | |
} | |
function roundNearest( number, nearest ){ | |
return Math.round( number / nearest ) * nearest; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment