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 scalb spurious "invalid" exceptions (bug 16770)


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


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