Ruby Always Round Up

The problem is that you’re currently calling ceil on 30.to_f. Here’s how Ruby evaluates it:

(67)/(30.to_f.ceil)
# .ceil turns the float into an integer again
(67)/(30.0.ceil)
# and now it's just an integer division, which will be 2
67/30 # = 2

To solve this, you can just add parenthesis:

puts (67/30.to_f).ceil  # = 3

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)