diff options
Diffstat (limited to 'src/numeric.c')
| -rw-r--r-- | src/numeric.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/numeric.c b/src/numeric.c index f99447d86..6c77a20c9 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -54,13 +54,11 @@ static mrb_value num_pow(mrb_state *mrb, mrb_value x) { mrb_value y; - mrb_bool both_int = FALSE; mrb_float d; mrb_get_args(mrb, "o", &y); - if (mrb_fixnum_p(x) && mrb_fixnum_p(y)) both_int = TRUE; d = pow(mrb_to_flo(mrb, x), mrb_to_flo(mrb, y)); - if (both_int && FIXABLE(d)) + if (mrb_fixnum_p(x) && mrb_fixnum_p(y) && FIXABLE(d)) return mrb_fixnum_value((mrb_int)d); return mrb_float_value(mrb, d); } @@ -397,22 +395,16 @@ static mrb_value flo_eq(mrb_state *mrb, mrb_value x) { mrb_value y; - volatile mrb_float a, b; - mrb_get_args(mrb, "o", &y); switch (mrb_type(y)) { case MRB_TT_FIXNUM: - b = (mrb_float)mrb_fixnum(y); - break; + return mrb_bool_value(mrb_float(x) == (mrb_float)mrb_fixnum(y)); case MRB_TT_FLOAT: - b = mrb_float(y); - break; + return mrb_bool_value(mrb_float(x) == (mrb_float)mrb_float(y)); default: return mrb_false_value(); } - a = mrb_float(x); - return mrb_bool_value(a == b); } /* 15.2.8.3.18 */ @@ -493,9 +485,7 @@ flo_infinite_p(mrb_state *mrb, mrb_value num) static mrb_value flo_finite_p(mrb_state *mrb, mrb_value num) { - mrb_float value = mrb_float(num); - - return mrb_bool_value(isfinite(value)); + return mrb_bool_value(isfinite(mrb_float(num))); } /* 15.2.9.3.10 */ |
