Created
April 27, 2011 19:24
-
-
Save cowboycoded/944985 to your computer and use it in GitHub Desktop.
Round by a fraction
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
def round_to_fraction(number,fraction = 0.5) | |
multiplier = 1.0 / fraction | |
(multiplier*number).round / multiplier | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment