diff options
| author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-11 15:11:14 +0000 |
|---|---|---|
| committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-11 15:11:14 +0000 |
| commit | 558e291b6a9903a16c811ad9715a895a5193dbb6 (patch) | |
| tree | 6040d6e4789412b77eb5e6a67ae1dc0d89a052e6 | |
| parent | 88d2dbd47b1b06b4f5d0c6d10706b5822d7686b2 (diff) | |
| download | ruby-558e291b6a9903a16c811ad9715a895a5193dbb6.tar.gz ruby-558e291b6a9903a16c811ad9715a895a5193dbb6.tar.xz ruby-558e291b6a9903a16c811ad9715a895a5193dbb6.zip | |
do not pass -infinity.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 3 | ||||
| -rw-r--r-- | lib/cmath.rb | 6 |
2 files changed, 4 insertions, 5 deletions
@@ -1,7 +1,6 @@ Thu Dec 11 23:48:00 2008 Tadayoshi Funaba <tadf@dotrb.org> - * 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 <kou@cozmixng.org> diff --git a/lib/cmath.rb b/lib/cmath.rb index 9705b277b..95a30c336 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 |
