static VALUE
fix_divmod(VALUE x, VALUE y)
{
if (FIXNUM_P(y)) {
long div, mod;
fixdivmod(FIX2LONG(x), FIX2LONG(y), &div, &mod);
return rb_assoc_new(LONG2NUM(div), LONG2NUM(mod));
}
switch (TYPE(y)) {
case T_BIGNUM:
x = rb_int2big(FIX2LONG(x));
return rb_big_divmod(x, y);
case T_FLOAT:
{
double div, mod;
volatile VALUE a, b;
flodivmod((double)FIX2LONG(x), RFLOAT_VALUE(y), &div, &mod);
a = dbl2ival(div);
b = DBL2NUM(mod);
return rb_assoc_new(a, b);
}
default:
return rb_num_coerce_bin(x, y, rb_intern("divmod"));
}
}