Commit cb1659c1 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #2066 from suzukaze/refactor-numeric2

Refactor numeric.c
parents c136d871 cdb49ab6
...@@ -980,8 +980,7 @@ lshift(mrb_state *mrb, mrb_int val, mrb_int width) ...@@ -980,8 +980,7 @@ lshift(mrb_state *mrb, mrb_int val, mrb_int width)
mrb_fixnum_value(width), mrb_fixnum_value(width),
mrb_fixnum_value(NUMERIC_SHIFT_WIDTH_MAX)); mrb_fixnum_value(NUMERIC_SHIFT_WIDTH_MAX));
} }
val = val << width; return mrb_fixnum_value(val << width);
return mrb_fixnum_value(val);
} }
static mrb_value static mrb_value
...@@ -1009,8 +1008,7 @@ fix_shift_get_width(mrb_state *mrb, mrb_int *width) ...@@ -1009,8 +1008,7 @@ fix_shift_get_width(mrb_state *mrb, mrb_int *width)
mrb_value y; mrb_value y;
mrb_get_args(mrb, "o", &y); mrb_get_args(mrb, "o", &y);
y = bit_coerce(mrb, y); *width = mrb_fixnum(bit_coerce(mrb, y));
*width = mrb_fixnum(y);
} }
/* 15.2.8.3.12 */ /* 15.2.8.3.12 */
...@@ -1075,11 +1073,7 @@ fix_rshift(mrb_state *mrb, mrb_value x) ...@@ -1075,11 +1073,7 @@ fix_rshift(mrb_state *mrb, mrb_value x)
static mrb_value static mrb_value
fix_to_f(mrb_state *mrb, mrb_value num) fix_to_f(mrb_state *mrb, mrb_value num)
{ {
mrb_float val; return mrb_float_value(mrb, (mrb_float)mrb_fixnum(num));
val = (mrb_float)mrb_fixnum(num);
return mrb_float_value(mrb, val);
} }
/* /*
......
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