You can use the round method to round a float or decimal number to its nearest integer. Here is an example:
main.rb127 chars8 lines
The round method uses the standard rounding rules, so a number that is exactly halfway between two integers will be rounded up to the nearest even integer. For example:
main.rb127 chars8 lines
If you want to always round up or down, you can use the ceil or floor methods, respectively:
main.rb126 chars8 lines
gistlibby LogSnag