This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Compute correct sign for ctanh (Inf + iy) (BZ #17118)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Andreas Schwab <schwab at suse dot de>
- Cc: <libc-alpha at sourceware dot org>
- Date: Mon, 11 Aug 2014 16:40:52 +0000
- Subject: Re: [PATCH] Compute correct sign for ctanh (Inf + iy) (BZ #17118)
- Authentication-results: sourceware.org; auth=none
- References: <mvmbnrr6n56 dot fsf at hawking dot suse dot de> <Pine dot LNX dot 4 dot 64 dot 1408111555000 dot 23898 at digraph dot polyomino dot org dot uk>
On Mon, 11 Aug 2014, Joseph S. Myers wrote:
> On Mon, 11 Aug 2014, Andreas Schwab wrote:
>
> > @@ -32,8 +32,15 @@ __ctanh (__complex__ double x)
> > {
> > if (__isinf_ns (__real__ x))
> > {
> > + int icls = fpclassify (__imag__ x);
> > + double sin2ix;
> > +
> > + if (__glibc_likely (icls != FP_SUBNORMAL))
> > + sin2ix = sin (2 * __imag__ x);
>
> That looks like it will cause spurious overflows if 2 * __imag__ x
> overflows (you can use sin * cos to get the right sign instead).
(sin * cos can be computed using __sincos, of course. To avoid possible
underflow exceptions from sin (DBL_MIN), fabs (__imag__ x) > something
may be a better condition than checking FP_SUBNORMAL.)
Also:
* What about arguments +/- Inf +/- iInf? sin (Inf) will raise INVALID,
but Annex G doesn't mention that as valid for this case of ctanh.
(Both these points indicate missing testsuite coverage.)
* ctan looks like it has the same issues as ctanh, so both should be
fixed, and testsuite coverage added, together.
--
Joseph S. Myers
joseph@codesourcery.com