modulo(p1)
public
Returns fix modulo other. See numeric.divmod for more information.
Show source
static VALUE
fix_mod(VALUE x, VALUE y)
{
if (FIXNUM_P(y)) {
long mod;
fixdivmod(FIX2LONG(x), FIX2LONG(y), 0, &mod);
return LONG2NUM(mod);
}
switch (TYPE(y)) {
case T_BIGNUM:
x = rb_int2big(FIX2LONG(x));
return rb_big_modulo(x, y);
case T_FLOAT:
{
double mod;
flodivmod((double)FIX2LONG(x), RFLOAT_VALUE(y), 0, &mod);
return DBL2NUM(mod);
}
default:
return rb_num_coerce_bin(x, y, '%');
}
}