From c181d1e7fa80b1cc0551f8fbd85ab6f7419b7887 Mon Sep 17 00:00:00 2001 From: Ray Chason Date: Thu, 8 Aug 2019 23:59:25 -0400 Subject: Implement Complex#abs in terms of Math.hypot Math.hypot avoids premature overflow and underflow --- mrbgems/mruby-complex/mrblib/complex.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mrbgems/mruby-complex/mrblib') 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 -- cgit v1.2.3