Created
August 24, 2013 21:08
-
-
Save gabrielstuff/6330432 to your computer and use it in GitHub Desktop.
Round function with float approximation. Very basic but useful.
Usage : betterRound(number, approximate);
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 betterRound(number, roundness){ | |
| if(roundness === undefined){ | |
| roundness = 0; | |
| } | |
| var round = Math.pow(10, roundness); | |
| return Math.ceil(number * round) / round; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment