Skip to content

Instantly share code, notes, and snippets.

@czj
Created June 23, 2020 11:14
Show Gist options
  • Save czj/bb2c905840b4c2a2951918f9961e4b15 to your computer and use it in GitHub Desktop.
Save czj/bb2c905840b4c2a2951918f9961e4b15 to your computer and use it in GitHub Desktop.
Ruby ceil() round() floor() with negative arguments
10.32.round(-1)
# 10
11.32.round(-1)
# 10
19.32.round(-1)
# 20
19.32.ceil(-1)
# 20
1919.32.ceil(-1)
# 1920
1919.32.round(-1)
# 1920
119.32.round(-1)
# 120
1419.32.round(-1)
# 1420
1414.32.round(-1)
# 1410
1414.32.ceil(-1)
# 1420
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment