Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Returns the smallest number greater than or equal to self with a precision of ndigits decimal digits.
When the precision is negative, the returned value is an integer with at least ndigits.abs trailing zeros:
555.ceil(-1)  # => 560
555.ceil(-2)  # => 600
-555.ceil(-2) # => -500
555.ceil(-3)  # => 1000
Returns self when ndigits is zero or positive.
555.ceil     # => 555
555.ceil(50) # => 555
Related: Integer#floor.
 
               static VALUE
int_ceil(int argc, VALUE* argv, VALUE num)
{
    int ndigits;

    if (!rb_check_arity(argc, 0, 1)) return num;
    ndigits = NUM2INT(argv[0]);
    if (ndigits >= 0) {
        return num;
    }
    return rb_int_ceil(num, ndigits);
}
            

Was this page useful?