I'm new to Ruby and I'm trying to figure out how ceil
and floor
works as I get different answers when a fraction or a decimal number is used (similar value). Below is what I have tried:
puts 8/3.ceil == 2 #=> true
puts 8/3.floor == 2 #=> true
puts 2.67.ceil == 2 #=> false
puts 2.67.floor == 2 #=> true
From my understanding, ceil
should return a number higher and floor
is a number lower. Hope someone can enlighten me on this. Thank you! :)