Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
def round_up_quarter(f)
result = (f * 4.0).round / 4.0
result > f ? result : result + 0.25
end
round_up_quarter(2.2) # => 2.25
round_up_quarter(4.6) # => 4.75
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment