Fix scalb spurious "invalid" exceptions (bug 16770)
Joseph S. Myers
joseph@codesourcery.com
Sat Mar 29 20:32:00 GMT 2014
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
More information about the Libc-alpha
mailing list