From 0d7f4ad8280aa09348488667986c656b7070521f Mon Sep 17 00:00:00 2001 From: tadf Date: Thu, 11 Dec 2008 15:11:14 +0000 Subject: [PATCH] do not pass -infinity. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 3 +-- lib/cmath.rb | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 370eed3ff6..5b8f211822 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,6 @@ Thu Dec 11 23:48:00 2008 Tadayoshi Funaba - * lib/cmath.rb (sqrt): should pass nan or infinity to the original - method. + * lib/cmath.rb (sqrt): should pass nan to the original method. Thu Dec 11 21:04:04 2008 Kouhei Sutou diff --git a/lib/cmath.rb b/lib/cmath.rb index 9705b277b0..95a30c336b 100644 --- a/lib/cmath.rb +++ b/lib/cmath.rb @@ -57,10 +57,10 @@ module CMath def sqrt(z) if z.real? - if z >= 0 || (Float === z && (z.nan? || z.infinite?)) - sqrt!(z) - else + if z < 0 Complex(0, sqrt!(-z)) + else + sqrt!(z) end else if z.imag < 0