diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-21 13:36:03 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-21 13:36:03 +0000 |
commit | f52ec74516e955d1325ad39dd5481ccaf043f244 (patch) | |
tree | acf3f92e7cf2f2c34e6b8eedde7c935ad1c7e75d /numeric.c | |
parent | 980c798a9713a1d8d1318fa15dd9014cc66ebf66 (diff) | |
download | ruby-f52ec74516e955d1325ad39dd5481ccaf043f244.tar.gz |
* internal.h (rb_fix_divmod_fix): like r54213, use FIX2NUM only if
x == FIXNUM_MIN && y == -1. This must be a rare case and it is
expected compiler to handle well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'numeric.c')
-rw-r--r-- | numeric.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -3135,7 +3135,7 @@ fix_divide(VALUE x, VALUE y, ID op) { if (FIXNUM_P(y)) { if (FIX2LONG(y) == 0) rb_num_zerodiv(); - return LONG2NUM(rb_div(FIX2LONG(x), FIX2LONG(y))); + return rb_fix_div_fix(x, y); } else if (RB_TYPE_P(y, T_BIGNUM)) { x = rb_int2big(FIX2LONG(x)); @@ -3207,7 +3207,7 @@ fix_mod(VALUE x, VALUE y) { if (FIXNUM_P(y)) { if (FIX2LONG(y) == 0) rb_num_zerodiv(); - return LONG2FIX(rb_mod(FIX2LONG(x), FIX2LONG(y))); + return rb_fix_mod_fix(x, y); } else if (RB_TYPE_P(y, T_BIGNUM)) { x = rb_int2big(FIX2LONG(x)); @@ -3231,10 +3231,10 @@ static VALUE fix_divmod(VALUE x, VALUE y) { if (FIXNUM_P(y)) { - long div, mod; + VALUE div, mod; if (FIX2LONG(y) == 0) rb_num_zerodiv(); - rb_divmod(FIX2LONG(x), FIX2LONG(y), &div, &mod); - return rb_assoc_new(LONG2NUM(div), LONG2FIX(mod)); + rb_fix_divmod_fix(x, y, &div, &mod); + return rb_assoc_new(div, mod); } else if (RB_TYPE_P(y, T_BIGNUM)) { x = rb_int2big(FIX2LONG(x)); |