diff options
author | das <das@FreeBSD.org> | 2011-10-21 06:30:16 +0000 |
---|---|---|
committer | das <das@FreeBSD.org> | 2011-10-21 06:30:16 +0000 |
commit | 5e302d8d6ba6877b2fd08509d5168ca989b444a3 (patch) | |
tree | 92376eadf1c1c16e4b1d72ea8bccd2ea949839d7 /lib/msun/src | |
parent | 3578083bd5e5c8cc7b2d82f501d5901051537ae4 (diff) | |
download | FreeBSD-src-5e302d8d6ba6877b2fd08509d5168ca989b444a3.zip FreeBSD-src-5e302d8d6ba6877b2fd08509d5168ca989b444a3.tar.gz |
Fix a corner case: tan(large + Inf i) == NaN + NaN i.
Diffstat (limited to 'lib/msun/src')
-rw-r--r-- | lib/msun/src/s_ctanh.c | 7 | ||||
-rw-r--r-- | lib/msun/src/s_ctanhf.c | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/msun/src/s_ctanh.c b/lib/msun/src/s_ctanh.c index 1705e90..d427e28 100644 --- a/lib/msun/src/s_ctanh.c +++ b/lib/msun/src/s_ctanh.c @@ -108,6 +108,13 @@ ctanh(double complex z) } /* + * ctanh(x + i NAN) = NaN + i NaN + * ctanh(x +- i Inf) = NaN + i NaN + */ + if (!isfinite(y)) + return (cpack(y - y, y - y)); + + /* * ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the * approximation sinh^2(huge) ~= exp(2*huge) / 4. * We use a modified formula to avoid spurious overflow. diff --git a/lib/msun/src/s_ctanhf.c b/lib/msun/src/s_ctanhf.c index ae833df..4be28d8 100644 --- a/lib/msun/src/s_ctanhf.c +++ b/lib/msun/src/s_ctanhf.c @@ -57,6 +57,9 @@ ctanhf(float complex z) copysignf(0, isinf(y) ? y : sinf(y) * cosf(y)))); } + if (!isfinite(y)) + return (cpackf(y - y, y - y)); + if (ix >= 0x41300000) { /* x >= 11 */ float exp_mx = expf(-fabsf(x)); return (cpackf(copysignf(1, x), |