Skip to content

Instantly share code, notes, and snippets.

@gmgent
Created March 8, 2011 19:07
Show Gist options
  • Select an option

  • Save gmgent/860803 to your computer and use it in GitHub Desktop.

Select an option

Save gmgent/860803 to your computer and use it in GitHub Desktop.
class Float
def round_to(x)
(self * 10**x).round.to_f / 10**x
end
def ceil_to(x)
(self * 10**x).ceil.to_f / 10**x
end
def floor_to(x)
(self * 10**x).floor.to_f / 10**x
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment