diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-02 12:40:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-02 12:40:51 +0000 |
commit | 83cfc94563c3f5eb0339f4cab280e5219a179a0c (patch) | |
tree | 84456645fc0b9232878993c38995c2b3a2e80696 /math.c | |
parent | aa8e9c63ad0300df0eed07c3fe4f19d859a63673 (diff) |
math.c: tanh overflow
* math.c (tanh): check overflows, and return +-1.0.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'math.c')
-rw-r--r-- | math.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -283,7 +283,9 @@ math_sinh(VALUE obj, VALUE x) double tanh(double x) { - return sinh(x) / cosh(x); + const double c = cosh(x); + if (!isinf(c)) return sinh(x) / c; + return x > 0 ? 1.0 : -1.0; } #endif |