From 9d774bc01141ee789b6d31b9891bc627c3647e54 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 30 Jul 2022 09:08:02 +0900 Subject: [PATCH] numeric.c (flo_ceil_floor): return bigint if possible. --- src/numeric.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/numeric.c b/src/numeric.c index e90b70c5f..07df6e489 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -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); }