Skip to content

Instantly share code, notes, and snippets.

@aratak
Created August 20, 2013 11:47
Show Gist options
  • Save aratak/6280400 to your computer and use it in GitHub Desktop.
Save aratak/6280400 to your computer and use it in GitHub Desktop.
notches_rounding.rb
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