mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
numeric.c (int_rounding): unify code duplication.
This commit is contained in:
+1
-8
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user