Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Integer#ceil

int.ceil([ndigits]) → integer or float

Returns the smallest number greater than or equal to int with a precision of ndigits decimal digits (default: 0).

When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros.

Returns self when ndigits is zero or positive.

Example
1.ceil           #=> 1
1.ceil(2)        #=> 1
18.ceil(-1)      #=> 20
(-18).ceil(-1)   #=> -10
See also #bit_length #chr #anybits? #coerce also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1