numeric.c (int_rounding): unify code duplication.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-08-10 10:04:45 +09:00
parent 4e735eb8ba
commit 8cdf14c06b
+1 -8
View File
@@ -1582,14 +1582,7 @@ int_rounding(mrb_state *mrb, mrb_value x, double (*func)(double))
mrb_float f = mrb_as_float(mrb, x);
mrb_float d = pow(10, -(double)nd);
f = func(f / d) * d;
if (!FIXABLE_FLOAT(f)) {
#ifdef MRB_USE_BIGINT
return mrb_bint_new_float(mrb, f);
#else
mrb_int_overflow(mrb, "rounding");
#endif
}
return mrb_int_value(mrb, (mrb_int)f);
return flo_rounding_int(mrb, f);
}
/* 15.2.8.3.14 Integer#ceil */