[前][次][番号順一覧][スレッド一覧]

ruby-changes:29637

From: charliesome <ko1@a...>
Date: Sat, 29 Jun 2013 01:10:31 +0900 (JST)
Subject: [ruby-changes:29637] charliesome:r41689 (trunk): * numeric.c (fix_mul): remove FIT_SQRT_LONG test as it was causing

charliesome	2013-06-29 01:09:08 +0900 (Sat, 29 Jun 2013)

  New Revision: 41689

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41689

  Log:
    * 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

  Modified files:
    trunk/ChangeLog
    trunk/numeric.c
    trunk/test/ruby/test_integer_comb.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41688)
+++ ChangeLog	(revision 41689)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jun 29 01:08:00 2013  Charlie Somerville  <charliesome@r...>
+
+	* 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@f...>
 
 	* bignum.c (rb_big_and): Allocate new bignum with same size to shorter
Index: numeric.c
===================================================================
--- numeric.c	(revision 41688)
+++ numeric.c	(revision 41689)
@@ -2728,8 +2728,6 @@ fix_mul(VALUE x, VALUE y) https://github.com/ruby/ruby/blob/trunk/numeric.c#L2728
 	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));
Index: test/ruby/test_integer_comb.rb
===================================================================
--- test/ruby/test_integer_comb.rb	(revision 41688)
+++ test/ruby/test_integer_comb.rb	(revision 41689)
@@ -187,6 +187,7 @@ class TestIntegerComb < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_integer_comb.rb#L187
         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}")

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]