diff options
Diffstat (limited to 'lib/cmath.rb')
-rw-r--r-- | lib/cmath.rb | 6 |
1 files changed, 3 insertions, 3 deletions
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 |