Method: Integer#ceil

Defined in:
numeric.c

#ceil([ndigits]) ⇒ Integer, 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.

1.ceil           #=> 1
1.ceil(2)        #=> 1
18.ceil(-1)      #=> 20
(-18).ceil(-1)   #=> -10

Returns:



5315
5316
5317
5318
5319
5320
5321
5322
5323
5324
5325
5326
# File 'numeric.c', line 5315

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);
}