mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* numeric.c (fix_mul): remove FIT_SQRT_LONG test as it was causing
fix_mul to return an incorrect result for -2147483648*-2147483648 on 64 bit platforms * test/ruby/test_integer_comb.rb (class TestIntegerComb): add test case git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
da0c4e5e11
commit
7ffd3e9444
3 changed files with 9 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
Fri Jun 29 01:08:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
|
||||
|
||||
* numeric.c (fix_mul): remove FIT_SQRT_LONG test as it was causing
|
||||
fix_mul to return an incorrect result for -2147483648*-2147483648
|
||||
on 64 bit platforms
|
||||
|
||||
* test/ruby/test_integer_comb.rb (class TestIntegerComb): add test case
|
||||
|
||||
Fri Jun 28 12:26:53 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* bignum.c (rb_big_and): Allocate new bignum with same size to shorter
|
||||
|
|
|
@ -2728,8 +2728,6 @@ fix_mul(VALUE x, VALUE y)
|
|||
if (FIXABLE(d)) return LONG2FIX(d);
|
||||
return rb_ll2inum(d);
|
||||
#else
|
||||
if (FIT_SQRT_LONG(a) && FIT_SQRT_LONG(b))
|
||||
return LONG2FIX(a*b);
|
||||
if (a == 0) return x;
|
||||
if (MUL_OVERFLOW_FIXNUM_P(a, b))
|
||||
r = rb_big_mul(rb_int2big(a), rb_int2big(b));
|
||||
|
|
|
@ -187,6 +187,7 @@ class TestIntegerComb < Test::Unit::TestCase
|
|||
c = a * b
|
||||
check_class(c)
|
||||
assert_equal(b * a, c, "#{a} * #{b}")
|
||||
assert_equal(b.send(:*, a), c, "#{a} * #{b}")
|
||||
assert_equal(b, c / a, "(#{a} * #{b}) / #{a}") if a != 0
|
||||
assert_equal(a.abs * b.abs, (a * b).abs, "(#{a} * #{b}).abs")
|
||||
assert_equal((a-100)*(b-100)+(a-100)*100+(b-100)*100+10000, c, "#{a} * #{b}")
|
||||
|
|
Loading…
Add table
Reference in a new issue