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: Fix csin, csinh, ccos, ccosh missing underflows (bug 15405)


On Fri, 26 Apr 2013, Andreas Jaeger wrote:

> > +	  if (fabs (__real__ retval) < DBL_MIN)
> > +	    {
> > +	      volatile double force_underflow
> > +		= __real__ retval * __real__ retval;
> > +	      (void) force_underflow;
> > +	    }
> > +	  if (fabs (__imag__ retval) < DBL_MIN)
> > +	    {
> > +	      volatile double force_underflow
> > +		= __imag__ retval * __imag__ retval;
> > +	      (void) force_underflow;
> > +	    }
> 
> Couldn't this be an else if? I expect we only need to raise underflow once if
> both are underflowing, aren't we?

Generically the reason to avoid "else if" in such cases is to avoid issues 
in the case where the first part was an exact zero (so meets the if 
condition, but the multiplication shouldn't and doesn't cause underflow) 
while the second is a genuine underflow that needs the multiplication to 
get the exception.  Maybe the case of exact zero doesn't occur here, but 
it's more obvious without the "else" that the exception will always be 
raised if needed (and I don't think either the zero case or the underflow 
case is going to be the common case).

-- 
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]