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

ruby-changes:16967

From: mrkn <ko1@a...>
Date: Wed, 11 Aug 2010 23:31:00 +0900 (JST)
Subject: [ruby-changes:16967] Ruby:r28964 (trunk): * lib/cmath.rb (CMath.sqrt): use floating-point value. [Bug #3678]

mrkn	2010-08-11 23:30:47 +0900 (Wed, 11 Aug 2010)

  New Revision: 28964

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

  Log:
    * lib/cmath.rb (CMath.sqrt): use floating-point value.  [ruby-core:31672] [Bug #3678]
    * test/test_cmath.rb: added for testing lib/cmath.rb.

  Added files:
    trunk/test/test_cmath.rb
  Modified files:
    trunk/ChangeLog
    trunk/lib/cmath.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 28963)
+++ ChangeLog	(revision 28964)
@@ -1,3 +1,10 @@
+Wed Aug 11 23:28:22 2010  Kenta Murata  <mrkn@m...>
+
+	* lib/cmath.rb (CMath.sqrt): use floating-point value.
+	[ruby-core:31672] [Bug #3678]
+
+	* test/test_cmath.rb: added for testing lib/cmath.rb.
+
 Wed Aug 11 20:57:25 2010  Kazuhiro NISHIYAMA  <zn@m...>
 
 	* NEWS: merge from branches/ruby_1_9_2, and move io/console.
Index: lib/cmath.rb
===================================================================
--- lib/cmath.rb	(revision 28963)
+++ lib/cmath.rb	(revision 28964)
@@ -79,7 +79,7 @@
       else
 	r = z.abs
 	x = z.real
-	Complex(sqrt!((r + x) / 2), sqrt!((r - x) / 2))
+	Complex(sqrt!((r + x) / 2.0), sqrt!((r - x) / 2.0))
       end
     end
   end
Index: test/test_cmath.rb
===================================================================
--- test/test_cmath.rb	(revision 0)
+++ test/test_cmath.rb	(revision 28964)
@@ -0,0 +1,8 @@
+require 'test/unit'
+require 'cmath'
+
+class TestCMath < Test::Unit::TestCase
+  def test_sqrt
+    assert_equal CMath.sqrt(1.0.i), CMath.sqrt(1.i), '[ruby-core:31672]'
+  end
+end

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

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