aboutsummaryrefslogtreecommitdiff
path: root/math/s_ctan_template.c
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2017-12-07 16:21:00 +0000
committerJoseph Myers <joseph@codesourcery.com>2017-12-07 16:21:00 +0000
commitd15e83c5f5231d971472b5ffc9219d54056ca0f1 (patch)
treebbc07214991185682fd6fe1dada1907e3fe6608b /math/s_ctan_template.c
parentd89756ebe1905c1989179c2f1c2b10ef2fb3354e (diff)
downloadglibc-d15e83c5f5231d971472b5ffc9219d54056ca0f1.zip
glibc-d15e83c5f5231d971472b5ffc9219d54056ca0f1.tar.gz
glibc-d15e83c5f5231d971472b5ffc9219d54056ca0f1.tar.bz2
Fix ctanh (0 + i NaN), ctanh (0 + i Inf) (bug 22568, DR#471).
As per C11 DR#471, ctanh (0 + i NaN) and ctanh (0 + i Inf) should return 0 + i NaN (with "invalid" exception in the second case but not the first), not NaN + i NaN. This has corresponding implications for ctan since its special cases are defined by ctan (z) = -i ctanh (iz). This patch implements these cases for ctanh and ctan, updating tests accordingly. Tested for x86_64. [BZ #22568] * math/s_ctan_template.c (M_DECL_FUNC (__ctan)): Set imaginary part of result to imaginary part of argument if it is zero and the real part of the argument is not finite. * math/s_ctanh_template.c (M_DECL_FUNC (__ctanh)): Set real part of result to real part of argument if it is zero and the imaginary part of the argument is not finite.
Diffstat (limited to 'math/s_ctan_template.c')
-rw-r--r--math/s_ctan_template.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/math/s_ctan_template.c b/math/s_ctan_template.c
index 723156e..644d7e6 100644
--- a/math/s_ctan_template.c
+++ b/math/s_ctan_template.c
@@ -49,7 +49,10 @@ M_DECL_FUNC (__ctan) (CFLOAT x)
else
{
__real__ res = M_NAN;
- __imag__ res = M_NAN;
+ if (__imag__ x == 0)
+ __imag__ res = __imag__ x;
+ else
+ __imag__ res = M_NAN;
if (isinf (__real__ x))
feraiseexcept (FE_INVALID);