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

ruby-changes:23212

From: naruse <ko1@a...>
Date: Mon, 9 Apr 2012 02:54:29 +0900 (JST)
Subject: [ruby-changes:23212] naruse:r35262 (trunk): * complex.c (nucomp_expt): the result of f_complex_new2 may be a fixnum

naruse	2012-04-09 02:53:51 +0900 (Mon, 09 Apr 2012)

  New Revision: 35262

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

  Log:
    * complex.c (nucomp_expt): the result of f_complex_new2 may be a fixnum
      with mathn. [ruby-core:44170] [Bug #6267]

  Modified files:
    trunk/ChangeLog
    trunk/complex.c
    trunk/test/test_mathn.rb

Index: complex.c
===================================================================
--- complex.c	(revision 35261)
+++ complex.c	(revision 35262)
@@ -887,7 +887,7 @@
 		    if (r)
 			break;
 
-		    x = f_complex_new2(CLASS_OF(self),
+		    x = nucomp_s_new_internal(CLASS_OF(self),
 				       f_sub(f_mul(dat->real, dat->real),
 					     f_mul(dat->imag, dat->imag)),
 				       f_mul(f_mul(TWO, dat->real), dat->imag));
@@ -896,7 +896,10 @@
 		z = f_mul(z, x);
 		n--;
 	    }
-	    return z;
+	    {
+		get_dat1(z);
+		return f_complex_new2(CLASS_OF(self), dat->real, dat->imag);
+	    }
 	}
 	return f_expt(f_reciprocal(self), f_negate(other));
     }
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 35261)
+++ ChangeLog	(revision 35262)
@@ -1,3 +1,8 @@
+Mon Apr  9 02:52:03 2012  NARUSE, Yui  <naruse@r...>
+
+	* complex.c (nucomp_expt): the result of f_complex_new2 may be a fixnum
+	  with mathn. [ruby-core:44170] [Bug #6267]
+
 Sun Apr  8 22:46:01 2012  NARUSE, Yui  <naruse@r...>
 
 	* ext/json/generator/generator.c (generate_json_bignum):
Index: test/test_mathn.rb
===================================================================
--- test/test_mathn.rb	(revision 35261)
+++ test/test_mathn.rb	(revision 35262)
@@ -6,5 +6,6 @@
   def test_power
     assert_in_out_err ['-r', 'mathn', '-e', 'a=1**2;!a'], "", [], [], '[ruby-core:25740]'
     assert_in_out_err ['-r', 'mathn', '-e', 'a=(1<<126)**2;!a'], "", [], [], '[ruby-core:25740]'
+    assert_in_out_err ['-r', 'mathn/complex', '-e', 'a=Complex(0,1)**5;!a'], "", [], [], '[ruby-core:44170]'
   end
 end

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

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