diff options
author | gogotanaka <gogotanaka@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-24 23:53:21 +0000 |
---|---|---|
committer | gogotanaka <gogotanaka@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-24 23:53:21 +0000 |
commit | 0c3a0d6588c6fe44d43edbc54d3f92553a5a1705 (patch) | |
tree | 61e19adcc91bd07698c23b41e970fa9d6bef4741 /lib | |
parent | 0c4631b88013e159a9a13bad158911aad59408c1 (diff) | |
download | ruby-0c3a0d6588c6fe44d43edbc54d3f92553a5a1705.tar.gz |
* lib/cmath.rb (log): raise ArgumentError when more than 2 arguments
are passed. [ruby-core:66143] [Bug #10487]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cmath.rb | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/lib/cmath.rb b/lib/cmath.rb index aee577c97c..e0c9139f8f 100644 --- a/lib/cmath.rb +++ b/lib/cmath.rb @@ -66,20 +66,12 @@ module CMath # it will be the base of logarithm. # # log(Complex(0,0)) #=> -Infinity+0.0i - def log(*args) + def log(z, b=::Math::E) begin - z, b = args - unless b.nil? || b.kind_of?(Numeric) - raise TypeError, "Numeric Number required" - end - if z.real? and z >= 0 and (b.nil? or b >= 0) - log!(*args) + if z.real? && z >= 0 && b >= 0 + log!(z, b) else - a = Complex(log!(z.abs), z.arg) - if b - a /= log(b) - end - a + Complex(log!(z.abs), z.arg) / log(b) end rescue NoMethodError handle_no_method_error @@ -397,4 +389,3 @@ module CMath module_function :handle_no_method_error end - |