This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Fix scalb spurious "invalid" exceptions (bug 16770)
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Rich Felker <dalias at aerifal dot cx>
- Cc: <libc-alpha at sourceware dot org>
- Date: Sat, 29 Mar 2014 20:31:55 +0000
- Subject: Re: Fix scalb spurious "invalid" exceptions (bug 16770)
- Authentication-results: sourceware.org; auth=none
- References: <Pine dot LNX dot 4 dot 64 dot 1403291620110 dot 11808 at digraph dot polyomino dot org dot uk> <20140329190656 dot GY26358 at brightrain dot aerifal dot cx>
On Sat, 29 Mar 2014, Rich Felker wrote:
> > - if (__glibc_unlikely ((double) (int) fn != fn))
> > + if (__glibc_unlikely (fabs (fn) >= 0x1p31 || (double) (int) fn != fn))
>
> Off-by-one for the negative case: -0x1p31 is representable as int.
> Maybe it doesn't matter anyway, but if it does, you could test
> fn>=0x1p31 and fn<-0x1p31 separately.
The purpose of this check is to be safe: to avoid the cast if it might be
out of range; there is no functional need for the cast to occur just
because it's in range. Any threshold above 65000.0 (the arbitrary value
used in invalid_fn to decide whether to call __scalbn with a positive or
negative scale) would work as well here.
--
Joseph S. Myers
joseph@codesourcery.com