diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-18 13:39:11 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2010-02-18 13:39:11 +0000 |
commit | 54380d99f833eaac517c5be4f6753f015dcaed2d (patch) | |
tree | f3ddd9381ce7097fdfb54a3bef157a517c7ea476 | |
parent | a8fcae0858458eeed0504a0f91071146bac8fb74 (diff) | |
download | ruby-54380d99f833eaac517c5be4f6753f015dcaed2d.tar.gz |
* math.c (math_atanh): raise ERANGE without calling atanh if absolute
value is 1 to achieve platform-independent math. [ruby-core:28219]
* math.c (math_lgamma): return [Infinity, 1] without calling lgamma_r
if argument is infinity or -infinity. [ruby-core:28219]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | math.c | 7 |
2 files changed, 15 insertions, 0 deletions
@@ -1,3 +1,11 @@ +Thu Feb 18 22:31:15 2010 Yusuke Endoh <mame@tsg.ne.jp> + + * math.c (math_atanh): raise ERANGE without calling atanh if absolute + value is 1 to achieve platform-independent math. [ruby-core:28219] + + * math.c (math_lgamma): return [Infinity, 1] without calling lgamma_r + if argument is infinity or -infinity. [ruby-core:28219] + Thu Feb 18 22:28:00 2010 Kenta Murata <mrkn@mrkn.jp> * confiure.in: new --with-ext and --with-out-ext options for extmk. @@ -310,6 +310,10 @@ math_atanh(VALUE obj, VALUE x) Need_Float(x); errno = 0; d0 = RFLOAT_VALUE(x); + if (d0 == 1.0 || d0 == -1.0) { + errno = ERANGE; + rb_sys_fail("atanh"); + } d = atanh(d0); domain_check(d0, d, "atanh"); infinity_check(x, d, "atanh"); @@ -715,6 +719,9 @@ math_lgamma(VALUE obj, VALUE x) Need_Float(x); errno = 0; d0 = RFLOAT_VALUE(x); + if (isinf(d0)) { + return rb_assoc_new(DBL2NUM(INFINITY), INT2FIX(1)); + } d = lgamma_r(d0, &sign); domain_check(d0, d, "lgamma"); v = DBL2NUM(d); |