aboutsummaryrefslogtreecommitdiffstats
path: root/math.c
diff options
context:
space:
mode:
Diffstat (limited to 'math.c')
-rw-r--r--math.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/math.c b/math.c
index a781167d5e..eefcec3c93 100644
--- a/math.c
+++ b/math.c
@@ -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