summaryrefslogtreecommitdiff
path: root/lib/mathn.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mathn.rb')
-rw-r--r--lib/mathn.rb9
1 files changed, 1 insertions, 8 deletions
diff --git a/lib/mathn.rb b/lib/mathn.rb
index d6f2da02100..9cb9401e37b 100644
--- a/lib/mathn.rb
+++ b/lib/mathn.rb
@@ -103,14 +103,7 @@ module Math
def sqrt(a)
if a.kind_of?(Complex)
- abs = sqrt(a.real*a.real + a.imag*a.imag)
- x = sqrt((a.real + abs)/Rational(2))
- y = sqrt((-a.real + abs)/Rational(2))
- if a.imag >= 0
- Complex(x, y)
- else
- Complex(x, -y)
- end
+ sqrt!(a)
elsif a.respond_to?(:nan?) and a.nan?
a
elsif a >= 0