summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-complex/mrblib
diff options
context:
space:
mode:
authorRay Chason <[email protected]>2019-08-09 00:08:36 -0400
committerRay Chason <[email protected]>2019-08-09 00:08:36 -0400
commit1cd0ff0d42ea4fb385288d3bd2c440a1f46e08af (patch)
treece1ecd89ddb7d67171dfda216e6e82ac79c0b373 /mrbgems/mruby-complex/mrblib
parentc181d1e7fa80b1cc0551f8fbd85ab6f7419b7887 (diff)
downloadmruby-1cd0ff0d42ea4fb385288d3bd2c440a1f46e08af.tar.gz
mruby-1cd0ff0d42ea4fb385288d3bd2c440a1f46e08af.zip
Avoid overflow and underflow in Complex#/
Diffstat (limited to 'mrbgems/mruby-complex/mrblib')
-rw-r--r--mrbgems/mruby-complex/mrblib/complex.rb3
1 files changed, 1 insertions, 2 deletions
diff --git a/mrbgems/mruby-complex/mrblib/complex.rb b/mrbgems/mruby-complex/mrblib/complex.rb
index 1025e975e..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