Actions
Bug #3678
closedCMath.sqrt(1.i) results to 0.0+0.0i
Description
=begin
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))
-
endComplex(sqrt!((r + x) / 2.0), sqrt!((r - x) / 2.0)) end
end
=end
Actions
Like0
Like0Like0Like0Like0Like0Like0