ruby-changes:38520
From: usa <ko1@a...>
Date: Fri, 22 May 2015 20:57:50 +0900 (JST)
Subject: [ruby-changes:38520] usa:r50601 (trunk): * complex.c (f_complex_polar): simple bug reproduced only when y is
usa 2015-05-22 20:57:43 +0900 (Fri, 22 May 2015) New Revision: 50601 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50601 Log: * complex.c (f_complex_polar): simple bug reproduced only when y is a float but x is not a float. Modified files: trunk/ChangeLog trunk/complex.c trunk/test/ruby/test_complex.rb Index: complex.c =================================================================== --- complex.c (revision 50600) +++ complex.c (revision 50601) @@ -592,8 +592,8 @@ f_complex_polar(VALUE klass, VALUE x, VA https://github.com/ruby/ruby/blob/trunk/complex.c#L592 y = DBL2NUM(imag); } else { + y = f_mul(x, DBL2NUM(sin(arg))); x = f_mul(x, DBL2NUM(cos(arg))); - y = f_mul(y, DBL2NUM(sin(arg))); if (canonicalization && f_zero_p(y)) return x; } return nucomp_s_new_internal(klass, x, y); Index: ChangeLog =================================================================== --- ChangeLog (revision 50600) +++ ChangeLog (revision 50601) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Fri May 22 20:56:33 2015 NAKAMURA Usaku <usa@r...> + + * complex.c (f_complex_polar): simple bug reproduced only when y is + a float but x is not a float. + Fri May 22 19:42:06 2015 Nobuyoshi Nakada <nobu@r...> * process.c (rb_spawn_process): do not discard global escape Index: test/ruby/test_complex.rb =================================================================== --- test/ruby/test_complex.rb (revision 50600) +++ test/ruby/test_complex.rb (revision 50601) @@ -212,6 +212,7 @@ class Complex_Test < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/ruby/test_complex.rb#L212 def test_polar assert_equal([1,2], Complex.polar(1,2).polar) + assert_equal(Complex.polar(1.0, Math::PI * 2 / 3), Complex.polar(1, Math::PI * 2 / 3)) end def test_uplus -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/