This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Compute correct sign for ctanh (Inf + iy) (BZ #17118)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]