From e4bcd8a96ad4e091af6626a8c5cf24e69804af74 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 30 Jul 2022 09:05:21 +0900 Subject: [PATCH] numeric.c (mrb_float_to_integer): unify with flo_to_i(). --- src/numeric.c | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/numeric.c b/src/numeric.c index 442004ae9..daf803fb0 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -1036,7 +1036,6 @@ flo_to_i(mrb_state *mrb, mrb_value num) mrb_float f = mrb_float(num); mrb_check_num_exact(mrb, f); - if (!FIXABLE_FLOAT(f)) { #ifdef MRB_USE_BIGINT return mrb_bint_new_float(mrb, f); @@ -1583,27 +1582,10 @@ int_to_f(mrb_state *mrb, mrb_value num) MRB_API mrb_value mrb_float_to_integer(mrb_state *mrb, mrb_value x) { - mrb_int z = 0; - if (!mrb_float_p(x)) { mrb_raise(mrb, E_TYPE_ERROR, "non float value"); } - else { - mrb_float d = mrb_float(x); - - mrb_check_num_exact(mrb, d); - if (FIXABLE_FLOAT(d)) { - z = (mrb_int)d; - } - else { -#ifdef MRB_USE_BIGINT - return mrb_bint_new_float(mrb, d); -#else - mrb_raisef(mrb, E_RANGE_ERROR, "number (%v) too big for integer", x); -#endif - } - } - return mrb_int_value(mrb, z); + return flo_to_i(mrb, x); } #endif