Created
February 15, 2014 09:36
-
-
Save rusllonrails/9016770 to your computer and use it in GitHub Desktop.
JAVASCRIPT ROUND UP
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
app.round_up = (float, digits) -> | |
digits = (if not digits? then 2 else digits) | |
k = Math.pow(10, digits) | |
int = (float * k).toFixed(1) | |
rounded = Math.floor(int) | |
((rounded + ((if int - rounded < 0.5 then 0 else 1))) / k).toFixed 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment