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 pow of zero and infinity to large powers


On Tuesday, March 20, 2012 16:05:17 Joseph S. Myers wrote:
> This patch fixes various problems with zero and infinity to large
> powers (roughly, cases (4b), (5), (6) and (7) of bug 3866).  (I was
> originally intending to look at the patch in bug 369, but before
> adding comprehensive tests for powers of negative finite values it
> seemed appropriate to cover powers of negative zero and infinity -
> resulting in the testcases in this patch, and the code changes to make
> them pass.)
> 
> The general issue is x86 floating-to-integer conversion instructions
> requiring inputs in a certain range, so the exponents need checking
> first to make sure they are in that range (and in the powl case,
> there's a further issue that values in the range (-2^64, 2^64) could
> be odd integers but are too large to convert directly to integer, so
> fprem is used to reduce to 63 bits in that case).  pow and powf had
> bogus logic "OK, the value is an integer, but is the number of bits
> small enough so that all are coming from the mantissa?", which might
> be relevant if you were checking bits of the floating-point
> representation to see if it's odd - but is not relevant to this code
> which is checking the low bit of the result of converting to integer,
> rather than looking at the representation.  This bogus logic caused
> one test failure (pow (-0, -0x1.fffffffffffffp+52) returned +infinity
> instead of -infinity); I removed it in all cases.  One bug in the
> generic C pow, where it failed to raise divide-by-zero for zero to
> large negative powers, is also fixed.
> 
> One bug found in the course of testing, bug 13879 (a spurious overflow
> exception), was filed in Bugzilla and the exception marked as allowed
> with a comment pointing to the bug instead of fixing it (this looks
> like a bug in the wrapper calling __kernel_standard in certain cases,
> where it passes original long double arguments to __kernel_standard
> which takes double, so causing overflow exceptions from the
> conversion; probably all __kernel_standard calls need reviewing to
> work out how to address this issue and how many places it affects).
> 
> Tested x86 and x86_64.

Thanks a lot! This is ok,

Andreas
-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126


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