diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-17 00:16:01 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2014-03-17 00:16:01 +0900 |
| commit | 3687e1f97b8a3fd058791d30f5d6f58285a627c6 (patch) | |
| tree | 95c83ace18e45d610145fa200406b1369a5fbe97 /src | |
| parent | 55c1942b43b1e62956e6ce1798dc10fe742d617c (diff) | |
| parent | 0d82ada9229cb01279e087246fcd1bcb4d5ddd29 (diff) | |
| download | mruby-3687e1f97b8a3fd058791d30f5d6f58285a627c6.tar.gz mruby-3687e1f97b8a3fd058791d30f5d6f58285a627c6.zip | |
Merge branch 'master' of github.com:mruby/mruby
Diffstat (limited to 'src')
| -rw-r--r-- | src/numeric.c | 15 | ||||
| -rw-r--r-- | src/object.c | 4 |
2 files changed, 9 insertions, 10 deletions
diff --git a/src/numeric.c b/src/numeric.c index 38a05ae92..b0b80c523 100644 --- a/src/numeric.c +++ b/src/numeric.c @@ -690,10 +690,10 @@ mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y) mrb_int a; a = mrb_fixnum(x); - if (a == 0) return x; if (mrb_fixnum_p(y)) { mrb_int b, c; + if (a == 0) return x; b = mrb_fixnum(y); if (FIT_SQRT_INT(a) && FIT_SQRT_INT(b)) return mrb_fixnum_value(a*b); @@ -1131,10 +1131,10 @@ mrb_fixnum_plus(mrb_state *mrb, mrb_value x, mrb_value y) mrb_int a; a = mrb_fixnum(x); - if (a == 0) return y; if (mrb_fixnum_p(y)) { mrb_int b, c; + if (a == 0) return y; b = mrb_fixnum(y); c = a + b; if (((a < 0) ^ (b < 0)) == 0 && (a < 0) != (c < 0)) { @@ -1306,15 +1306,14 @@ num_cmp(mrb_state *mrb, mrb_value self) * and <code>other</code>. */ static mrb_value -flo_plus(mrb_state *mrb, mrb_value self) +flo_plus(mrb_state *mrb, mrb_value x) { - mrb_float x, y; - - x = mrb_float(self); - mrb_get_args(mrb, "f", &y); + mrb_value y; - return mrb_float_value(mrb, x + y); + mrb_get_args(mrb, "o", &y); + return mrb_float_value(mrb, mrb_float(x) + mrb_to_flo(mrb, y)); } + /* ------------------------------------------------------------------------*/ void mrb_init_numeric(mrb_state *mrb) diff --git a/src/object.c b/src/object.c index 5090e38cf..6d39254dd 100644 --- a/src/object.c +++ b/src/object.c @@ -338,7 +338,7 @@ mrb_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, const char mrb_value v; if (mrb_type(val) == type) return val; - v = convert_type(mrb, val, tname, method, 1/*Qtrue*/); + v = convert_type(mrb, val, tname, method, TRUE); if (mrb_type(v) != type) { mrb_raisef(mrb, E_TYPE_ERROR, "%S cannot be converted to %S by #%S", val, mrb_str_new_cstr(mrb, tname), mrb_str_new_cstr(mrb, method)); @@ -352,7 +352,7 @@ mrb_check_convert_type(mrb_state *mrb, mrb_value val, enum mrb_vtype type, const mrb_value v; if (mrb_type(val) == type && type != MRB_TT_DATA) return val; - v = convert_type(mrb, val, tname, method, 0/*Qfalse*/); + v = convert_type(mrb, val, tname, method, FALSE); if (mrb_nil_p(v) || mrb_type(v) != type) return mrb_nil_value(); return v; } |
