mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* math.c (math_log): should check argc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19448 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
83b381752e
commit
bdf81563bf
3 changed files with 6 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
|||
Sun Sep 21 21:52:41 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* math.c (math_log): should check argc.
|
||||
|
||||
Sun Sep 21 21:20:24 2008 Tadayoshi Funaba <tadf@dotrb.org>
|
||||
|
||||
* complex.c: added two macros.
|
||||
|
|
2
math.c
2
math.c
|
@ -353,7 +353,7 @@ math_log(int argc, VALUE *argv)
|
|||
Need_Float(x);
|
||||
errno = 0;
|
||||
d = log(RFLOAT_VALUE(x));
|
||||
if (!NIL_P(base)) {
|
||||
if (argc == 2) {
|
||||
Need_Float(base);
|
||||
d /= log(RFLOAT_VALUE(base));
|
||||
}
|
||||
|
|
|
@ -113,6 +113,7 @@ class TestMath < Test::Unit::TestCase
|
|||
assert_equal(1.0/0, Math.log(1.0/0))
|
||||
assert_raise(Errno::EDOM, Errno::ERANGE) { Math.log(0) }
|
||||
assert_raise(Errno::EDOM, Errno::ERANGE) { Math.log(-1) }
|
||||
assert_raise(TypeError) { Math.log(1,nil) }
|
||||
end
|
||||
|
||||
def test_log2
|
||||
|
|
Loading…
Reference in a new issue