Skip to content
Permalink
Browse files
integer range check was moved to mrb_flo_to_fixnum(); ref #3025
  • Loading branch information
matz committed Nov 19, 2015
1 parent 09abdcb commit 996417cabfd4f9422ab00530874837e2cf6a2cf6
Showing 2 changed files with 6 additions and 5 deletions.
@@ -796,10 +796,6 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
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);
}

0 comments on commit 996417c

Please sign in to comment.