aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--numeric.c2
-rw-r--r--test/ruby/test_integer_comb.rb1
3 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 065dc035ef..8bc49f6000 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/numeric.c b/numeric.c
index 79f8537fdd..6752becc00 100644
--- a/numeric.c
+++ b/numeric.c
@@ -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));
diff --git a/test/ruby/test_integer_comb.rb b/test/ruby/test_integer_comb.rb
index 3f5a0aa0a7..548102d034 100644
--- a/test/ruby/test_integer_comb.rb
+++ b/test/ruby/test_integer_comb.rb
@@ -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}")