numeric.c: simplifies `int_mod` definition.
MODIFY
src/numeric.c
src/numeric.c
@@ -1113,28 +1113,16 @@ intdivmod(mrb_state *mrb, mrb_int x, mrb_int y, mrb_int *divp, mrb_int *modp)
static mrb_value
int_mod(mrb_state *mrb, mrb_value x)
{
- mrb_value y = mrb_get_arg1(mrb);
- mrb_int a, b;
+ mrb_int a, b, mod;
+ mrb_get_args(mrb, "i", &b);
a = mrb_integer(x);
- if (mrb_integer_p(y) && a != MRB_INT_MIN && (b=mrb_integer(y)) != MRB_INT_MIN) {
- mrb_int mod = a % b;
+ mod = a % b;
if ((a < 0) != (b < 0) && mod != 0) {
mod += b;
}
return mrb_int_value(mrb, mod);
}
-#ifdef MRB_NO_FLOAT
- mrb_raise(mrb, E_TYPE_ERROR, "non integer modulo");
-#else
- else {
- mrb_float mod;
-
- flodivmod(mrb, (mrb_float)a, mrb_as_float(mrb, y), NULL, &mod);
- return mrb_float_value(mrb, mod);
- }
-#endif
-}
/*
* call-seq:

numeric.c: simplifies `int_mod` definition.