This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix csin, csinh, ccos, ccosh missing underflows (bug 15405)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Andreas Jaeger <aj at suse dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Fri, 26 Apr 2013 17:15:51 +0000
- Subject: Re: Fix csin, csinh, ccos, ccosh missing underflows (bug 15405)
- References: <Pine dot LNX dot 4 dot 64 dot 1304261547100 dot 27966 at digraph dot polyomino dot org dot uk> <517AB041 dot 30705 at suse dot com>
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