From: Heesob Park Date: 2010-08-11T11:44:10+09:00 Subject: [ruby-core:31672] [Bug #3678] CMath.sqrt(1.i) results to 0.0+0.0i Bug #3678: CMath.sqrt(1.i) results to 0.0+0.0i http://redmine.ruby-lang.org/issues/show/3678 Author: Heesob Park Status: Open, Priority: Normal Category: lib, Target version: 1.9.x ruby -v: ruby 1.9.3dev (2010-08-10 trunk 28955) [i386-mswin32_90] CMath.sqrt(1.i) should be equal to CMath.sqrt(1.0.i) But CMath.sqrt(1.i) gives wrong result. C:\>ruby -rcmath -e "p CMath.sqrt(1.i)" (0.0+0.0i) C:\>ruby -rcmath -e "p CMath.sqrt(1.0.i)" (0.7071067811865476+0.7071067811865476i) Here is the patch --- cmath.rb 2010-08-11 11:30:07.087219552 +0900 +++ cmath.rb.new 2010-08-11 11:31:14.647214876 +0900 @@ -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 ---------------------------------------- http://redmine.ruby-lang.org