From 96191db217c69f989c68121a2ceb06c24939b848 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Thu, 7 Jul 2005 23:31:46 +0000 Subject: [PATCH] * sysdeps/generic/s_ctanh.c (__ctanh): Handle case of zero den better. * sysdeps/generic/s_ctanhf.c (__ctanhf): Likewise. * sysdeps/generic/s_ctanhl.c (__ctanhl): Likewise. --- ChangeLog | 6 ++++++ sysdeps/generic/s_ctanh.c | 16 +++++++++++++--- sysdeps/generic/s_ctanhf.c | 16 +++++++++++++--- 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 866427f..6c5daee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-07-07 Ulrich Drepper + + * sysdeps/generic/s_ctanh.c (__ctanh): Handle case of zero den better. + * sysdeps/generic/s_ctanhf.c (__ctanhf): Likewise. + * sysdeps/generic/s_ctanhl.c (__ctanhl): Likewise. + 2005-04-13 H.J. Lu [BZ #974] diff --git a/sysdeps/generic/s_ctanh.c b/sysdeps/generic/s_ctanh.c index 971cd90..fe38dae 100644 --- a/sysdeps/generic/s_ctanh.c +++ b/sysdeps/generic/s_ctanh.c @@ -1,5 +1,5 @@ /* Complex hyperbole tangent for double. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -61,8 +61,18 @@ __ctanh (__complex__ double x) den = (__ieee754_cosh (2.0 * __real__ x) + cos2ix); - __real__ res = __ieee754_sinh (2.0 * __real__ x) / den; - __imag__ res = sin2ix / den; + if (den == 0.0) + { + __complex__ double ez = __cexp (x); + __complex__ double emz = __cexp (-x); + + res = (ez - emz) / (ez + emz); + } + else + { + __real__ res = __ieee754_sinh (2.0 * __real__ x) / den; + __imag__ res = sin2ix / den; + } } return res; diff --git a/sysdeps/generic/s_ctanhf.c b/sysdeps/generic/s_ctanhf.c index cfcabab..c331dba 100644 --- a/sysdeps/generic/s_ctanhf.c +++ b/sysdeps/generic/s_ctanhf.c @@ -1,5 +1,5 @@ /* Complex hyperbole tangent for float. - Copyright (C) 1997 Free Software Foundation, Inc. + Copyright (C) 1997, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1997. @@ -61,8 +61,18 @@ __ctanhf (__complex__ float x) den = (__ieee754_coshf (2.0 * __real__ x) + cos2ix); - __real__ res = __ieee754_sinhf (2.0 * __real__ x) / den; - __imag__ res = sin2ix / den; + if (den == 0.0f) + { + __complex__ float ez = __cexpf (x); + __complex__ float emz = __cexpf (-x); + + res = (ez - emz) / (ez + emz); + } + else + { + __real__ res = __ieee754_sinhf (2.0 * __real__ x) / den; + __imag__ res = sin2ix / den; + } } return res; -- 2.7.4