diff options
| author | Ray Chason <[email protected]> | 2019-08-08 23:59:25 -0400 |
|---|---|---|
| committer | Ray Chason <[email protected]> | 2019-08-08 23:59:25 -0400 |
| commit | c181d1e7fa80b1cc0551f8fbd85ab6f7419b7887 (patch) | |
| tree | 53cfe089a8a9505d0d1bb2c1ee6b67fe5cf7e254 /mrbgems/mruby-complex/mrblib | |
| parent | 438638b42e13297d38198b15f2fc007e0f5a44a8 (diff) | |
| download | mruby-c181d1e7fa80b1cc0551f8fbd85ab6f7419b7887.tar.gz mruby-c181d1e7fa80b1cc0551f8fbd85ab6f7419b7887.zip | |
Implement Complex#abs in terms of Math.hypot
Math.hypot avoids premature overflow and underflow
Diffstat (limited to 'mrbgems/mruby-complex/mrblib')
| -rw-r--r-- | mrbgems/mruby-complex/mrblib/complex.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/mrbgems/mruby-complex/mrblib/complex.rb b/mrbgems/mruby-complex/mrblib/complex.rb index 1a6f7e92e..1025e975e 100644 --- a/mrbgems/mruby-complex/mrblib/complex.rb +++ b/mrbgems/mruby-complex/mrblib/complex.rb @@ -62,7 +62,7 @@ class Complex < Numeric end def abs - Math.sqrt(abs2) + Math.hypot imaginary, real end alias_method :magnitude, :abs |
