Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method · added in Ruby 3.2

Integer#ceildiv

ceildiv(numeric) → integer

Returns the result of division self by numeric. rounded up to the nearest integer.

Example
3.ceildiv(3)   # => 1
4.ceildiv(3)   # => 2

4.ceildiv(-3)  # => -1
-4.ceildiv(3)  # => -1
-4.ceildiv(-3) # => 2

3.ceildiv(1.2) # => 3

Ruby version changes

  1. 3.2
See also #ceil #chr #bit_length #coerce also in 4.1 · 4.0 · 3.4 · 3.2