integer range check was moved to mrb_flo_to_fixnum(); ref #3025

parent 09abdcb5
......@@ -796,10 +796,6 @@ retry:
bin_retry:
switch (mrb_type(val)) {
case MRB_TT_FLOAT:
if (FIXABLE(mrb_float(val))) {
val = mrb_fixnum_value((mrb_int)mrb_float(val));
goto bin_retry;
}
val = mrb_flo_to_fixnum(mrb, val);
if (mrb_fixnum_p(val)) goto bin_retry;
break;
......
......@@ -964,7 +964,12 @@ mrb_flo_to_fixnum(mrb_state *mrb, mrb_value x)
if (isnan(d)) {
mrb_raise(mrb, E_FLOATDOMAIN_ERROR, "NaN");
}
z = (mrb_int)d;
if (FIXABLE(d)) {
z = (mrb_int)d;
}
else {
mrb_raisef(mrb, E_ARGUMENT_ERROR, "number (%S) too big for integer", x);
}
}
return mrb_fixnum_value(z);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment