Ruby Newbie homepage Ruby Newbie homepage

How to use

Quick guide

Official content
Returns the remainder after dividing self by other.
Examples:
11.remainder(4)              # => 3
11.remainder(-4)             # => 3
-11.remainder(4)             # => -3
-11.remainder(-4)            # => -3

12.remainder(4)              # => 0
12.remainder(-4)             # => 0
-12.remainder(4)             # => 0
-12.remainder(-4)            # => 0

13.remainder(4.0)            # => 1.0
13.remainder(Rational(4, 1)) # => (1/1)
 
               static VALUE
int_remainder(VALUE x, VALUE y)
{
    if (FIXNUM_P(x)) {
        return num_remainder(x, y);
    }
    else if (RB_BIGNUM_TYPE_P(x)) {
        return rb_big_remainder(x, y);
    }
    return Qnil;
}
            

Was this page useful?