Created
August 20, 2013 11:47
-
-
Save aratak/6280400 to your computer and use it in GitHub Desktop.
notches_rounding.rb
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
class Float | |
def notches_rounding(notches=2) | |
rounded = (self * notches).round / notches.to_f | |
rounded % 1 == 0 ? rounded.to_i : rounded | |
end | |
end unless Float.respond_to? :notches_rounding |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment