summaryrefslogtreecommitdiff
path: root/src/complex/ctanh.c
diff options
context:
space:
mode:
authorSzabolcs Nagy <nsz@port70.net>2015-04-21 23:04:11 +0000
committerRich Felker <dalias@aerifal.cx>2015-05-01 13:37:42 -0400
commitb02eed9c4841913d690a2d0029737d72615384fe (patch)
tree3309e83aa23e51ce15da864f21742eb296f103bb /src/complex/ctanh.c
parente98a54643ee95032baab883673628314e520012e (diff)
downloadmusl-b02eed9c4841913d690a2d0029737d72615384fe.tar.gz
musl-b02eed9c4841913d690a2d0029737d72615384fe.tar.bz2
musl-b02eed9c4841913d690a2d0029737d72615384fe.tar.xz
musl-b02eed9c4841913d690a2d0029737d72615384fe.zip
complex: fix ctanh(+-0+i*nan) and ctanh(+-0+-i*inf)
These cases were incorrect in C11 as described by http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1886.htm
Diffstat (limited to 'src/complex/ctanh.c')
-rw-r--r--src/complex/ctanh.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/complex/ctanh.c b/src/complex/ctanh.c
index 0461050d..3ba3a899 100644
--- a/src/complex/ctanh.c
+++ b/src/complex/ctanh.c
@@ -101,11 +101,13 @@ double complex ctanh(double complex z)
}
/*
+ * ctanh(+-0 + i NAN) = +-0 + i NaN
+ * ctanh(+-0 +- i Inf) = +-0 + i NaN
* ctanh(x + i NAN) = NaN + i NaN
* ctanh(x +- i Inf) = NaN + i NaN
*/
if (!isfinite(y))
- return CMPLX(y - y, y - y);
+ return CMPLX(x ? y - y : x, y - y);
/*
* ctanh(+-huge + i +-y) ~= +-1 +- i 2sin(2y)/exp(2x), using the