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

Merge pull request #2248 from carsonmcdonald/mulfix

Another change to fix issue #2244
parents 1a462131 f0fed9db
...@@ -702,7 +702,8 @@ mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y) ...@@ -702,7 +702,8 @@ mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y)
a = mrb_fixnum(x); a = mrb_fixnum(x);
if (mrb_fixnum_p(y)) { if (mrb_fixnum_p(y)) {
mrb_int b, c; mrb_float c;
mrb_int b;
if (a == 0) return x; if (a == 0) return x;
b = mrb_fixnum(y); b = mrb_fixnum(y);
......
...@@ -1729,19 +1729,24 @@ RETRY_TRY_BLOCK: ...@@ -1729,19 +1729,24 @@ RETRY_TRY_BLOCK:
switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) { switch (TYPES2(mrb_type(regs[a]),mrb_type(regs[a+1]))) {
case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM): case TYPES2(MRB_TT_FIXNUM,MRB_TT_FIXNUM):
{ {
mrb_int x, y, z; mrb_value z;
x = mrb_fixnum(regs[a]); z = mrb_fixnum_mul(mrb, regs[a], regs[a+1]);
y = mrb_fixnum(regs[a+1]);
z = x * y; switch (mrb_type(z)) {
#ifdef MRB_WORD_BOXING case MRB_TT_FIXNUM:
z = (z << MRB_FIXNUM_SHIFT) / (1 << MRB_FIXNUM_SHIFT); {
#endif SET_INT_VALUE(regs[a], mrb_fixnum(z));
if (x != 0 && z/x != y) {
SET_FLT_VALUE(mrb, regs[a], (mrb_float)x * (mrb_float)y);
} }
else { break;
SET_INT_VALUE(regs[a], z); case MRB_TT_FLOAT:
{
SET_FLT_VALUE(mrb, regs[a], mrb_float(z));
}
break;
default:
/* cannot happen */
break;
} }
} }
break; break;
......
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