numeric.c (flo_ceil_floor): return bigint if possible.

This commit is contained in:
Yukihiro "Matz" Matsumoto
2022-07-30 09:08:02 +09:00
parent eb392cb643
commit 9d774bc011
+7
View File
@@ -850,6 +850,13 @@ flo_ceil_floor(mrb_state *mrb, mrb_value num, double (*func)(double))
f = func(f);
}
mrb_check_num_exact(mrb, f);
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);
}