/*
* call-seq:
* flt.divmod(numeric) => array
*
* See <code>Numeric#divmod</code>.
*/
static VALUE
flo_divmod(x, y)
VALUE x, y;
{
double fy, div, mod, val;
volatile VALUE a, b;
switch (TYPE(y)) {
case T_FIXNUM:
fy = (double)FIX2LONG(y);
break;
case T_BIGNUM:
fy = rb_big2dbl(y);
break;
case T_FLOAT:
fy = RFLOAT(y)->value;
break;
default:
return rb_num_coerce_bin(x, y);
}
flodivmod(RFLOAT(x)->value, fy, &div, &mod);
if (FIXABLE(div)) {
val = round(div);
a = LONG2FIX(val);
}
else {
a = rb_dbl2big(div);
}
b = rb_float_new(mod);
return rb_assoc_new(a, b);
}