Method: Integer#remainder
- Defined in:
- numeric.c
#remainder(numeric) ⇒ Object
Returns the remainder after dividing int
by numeric
.
x.remainder(y)
means x-y*(x/y).truncate
.
5.remainder(3) #=> 2
-5.remainder(3) #=> -2
5.remainder(-3) #=> 2
-5.remainder(-3) #=> -2
5.remainder(1.5) #=> 0.5
See Numeric#divmod.
3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 |
# File 'numeric.c', line 3901
static VALUE
int_remainder(VALUE x, VALUE y)
{
if (FIXNUM_P(x)) {
return num_remainder(x, y);
}
else if (RB_TYPE_P(x, T_BIGNUM)) {
return rb_big_remainder(x, y);
}
return Qnil;
}
|