mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* insns.def (opt_plus): simply use LONG2NUM() instead of wrongly
complex overflow case. * insns.def (opt_sub): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0e5f9aeaea
commit
2708fb6ba7
3 changed files with 15 additions and 13 deletions
|
@ -1,3 +1,10 @@
|
|||
Tue Feb 16 04:42:13 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
* insns.def (opt_plus): simply use LONG2NUM() instead of wrongly
|
||||
complex overflow case.
|
||||
|
||||
* insns.def (opt_sub): ditto.
|
||||
|
||||
Tue Feb 16 02:49:41 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* tool/rbinstall.rb (without_destdir): compare with the destdir
|
||||
|
|
15
insns.def
15
insns.def
|
@ -1332,12 +1332,7 @@ opt_plus
|
|||
a = FIX2LONG(recv);
|
||||
b = FIX2LONG(obj);
|
||||
c = a + b;
|
||||
if (FIXABLE(c)) {
|
||||
val = LONG2FIX(c);
|
||||
}
|
||||
else {
|
||||
val = rb_big_plus(rb_int2big(a), rb_int2big(b));
|
||||
}
|
||||
val = LONG2NUM(c);
|
||||
#endif
|
||||
}
|
||||
else if (FLONUM_2_P(recv, obj) &&
|
||||
|
@ -1387,13 +1382,7 @@ opt_minus
|
|||
a = FIX2LONG(recv);
|
||||
b = FIX2LONG(obj);
|
||||
c = a - b;
|
||||
|
||||
if (FIXABLE(c)) {
|
||||
val = LONG2FIX(c);
|
||||
}
|
||||
else {
|
||||
val = rb_big_minus(rb_int2big(a), rb_int2big(b));
|
||||
}
|
||||
val = LONG2NUM(c);
|
||||
}
|
||||
else if (FLONUM_2_P(recv, obj) &&
|
||||
BASIC_OP_UNREDEFINED_P(BOP_MINUS, FLOAT_REDEFINED_OP_FLAG)) {
|
||||
|
|
|
@ -37,10 +37,14 @@ class TestFixnum < Test::Unit::TestCase
|
|||
|
||||
def test_plus
|
||||
assert_equal(0x40000000, 0x3fffffff+1)
|
||||
assert_equal(0x7ffffffe, 0x3fffffff+0x3fffffff)
|
||||
assert_equal(0x4000000000000000, 0x3fffffffffffffff+1)
|
||||
assert_equal(0x7ffffffffffffffe, 0x3fffffffffffffff+0x3fffffffffffffff)
|
||||
assert_equal(-0x40000001, (-0x40000000)+(-1))
|
||||
assert_equal(-0x4000000000000001, (-0x4000000000000000)+(-1))
|
||||
assert_equal(-0x7ffffffe, (-0x3fffffff)+(-0x3fffffff))
|
||||
assert_equal(-0x80000000, (-0x40000000)+(-0x40000000))
|
||||
assert_equal(-0x8000000000000000, (-0x4000000000000000)+(-0x4000000000000000))
|
||||
end
|
||||
|
||||
def test_sub
|
||||
|
@ -49,6 +53,8 @@ class TestFixnum < Test::Unit::TestCase
|
|||
assert_equal(-0x40000001, (-0x40000000)-1)
|
||||
assert_equal(-0x4000000000000001, (-0x4000000000000000)-1)
|
||||
assert_equal(-0x80000000, (-0x40000000)-0x40000000)
|
||||
assert_equal(0x7fffffffffffffff, 0x3fffffffffffffff-(-0x4000000000000000))
|
||||
assert_equal(-0x8000000000000000, -0x4000000000000000-0x4000000000000000)
|
||||
end
|
||||
|
||||
def test_mult
|
||||
|
|
Loading…
Reference in a new issue