Created
September 12, 2012 10:04
-
-
Save rickclare/3705700 to your computer and use it in GitHub Desktop.
Rounding Example
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
if res > 1 | |
# round to nearest 0.5L | |
res = ( Math.round(res*2)/2 ).toFixed(1) | |
else | |
# round to nearest 0.05L | |
res = ( Math.round(res*20)/20 ).toFixed(2) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if res > 0.75
round to nearest 0.5L (e.g. 1, 1.5, 2.0 etc)
if res > 0.05 and < 0.75
round to nearest 0.05L (e.g. 0.05, 0.10, 0.15 etc.)
else
give # to two decimal places (e.g. 0.01, 0.02, 0.3 etc.)