summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-complex/mrblib/complex.rb
diff options
context:
space:
mode:
Diffstat (limited to 'mrbgems/mruby-complex/mrblib/complex.rb')
-rw-r--r--mrbgems/mruby-complex/mrblib/complex.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/mrbgems/mruby-complex/mrblib/complex.rb b/mrbgems/mruby-complex/mrblib/complex.rb
index 1a6f7e92e..f32b84c8b 100644
--- a/mrbgems/mruby-complex/mrblib/complex.rb
+++ b/mrbgems/mruby-complex/mrblib/complex.rb
@@ -45,8 +45,7 @@ class Complex < Numeric
def /(rhs)
if rhs.is_a? Complex
- div = rhs.real * rhs.real + rhs.imaginary * rhs.imaginary
- Complex((real * rhs.real + imaginary * rhs.imaginary) / div, (rhs.real * imaginary - real * rhs.imaginary) / div)
+ __div__(rhs)
elsif rhs.is_a? Numeric
Complex(real / rhs, imaginary / rhs)
end
@@ -62,7 +61,7 @@ class Complex < Numeric
end
def abs
- Math.sqrt(abs2)
+ Math.hypot imaginary, real
end
alias_method :magnitude, :abs