This is the mail archive of the
mailing list for the glibc project.
Re: [email@example.com] libc/2269: triginometric argument reductionerror in libm
- To: Geoff Keating <geoffk at redhat dot com>
- Subject: Re: [firstname.lastname@example.org] libc/2269: triginometric argument reductionerror in libm
- From: Bruce Allen <ballen at gravity dot phys dot uwm dot edu>
- Date: Sun, 20 May 2001 15:14:22 -0500 (CDT)
- cc: ballen at gravity dot phys dot uwm dot edu, aj at suse dot de, libc-alpha at sources dot redhat dot com, ballen at uwm dot edu, moshier at mediaone dot net
Interesting way to spend a Sunday afternoon... I should be working on the
house and getting caught up in the office!
> > > Someone needs to fix libc/sysdeps/i386/fpu/s_sin.S so that it does
> > > proper range reduction, I think. It works fine on non-x86 chips.
> > >
> > > Intel's manual (I was looking at the 'Pentium Processor Family
> > > Developer's Manual, volume 3') has some spectacularly bad advice on
> > > how to do range reduction. I would suggest ignoring it.
> > Geoff,
> > Could you please give a URL for this manual? I'm familiar enough with the
> > problems of range reduction to be interested in seeing how they got it
> > wrong.
> I don't remember where I got it from, other than it was Intel's web
> site, but they advise that you should use the same value of pi as the
> value used internally for range reduction, which is accurate to 66
> bits, or that you should reduce all arguments down to less than pi/4
> in software. Neither is necessary, since the builtin fsin opcode
> is guaranteed accurate up to 2^63, so it is only necessary to reduce
> outside that range.
This I think may be the root of the problem. If the internal value of pi
used for range reduction is only good to 66 bits, this won't give enough
accuracy to even cover the range of IEEE752 single-precision floats. As
you point out, this will be enough to cover arguments up to 2^63.
However since the range of normalized IEEE754 single precision floats is
up to 1.111...1 x 2^127 (note: there are a total of 24 1's in the
preceeding string, and the 1.111...1 is in base 2) this internal value
good to 66 bits is not nearly sufficient. Typical libraries store about
400 bits of 2/Pi, 4/Pi, or 8/Pi to use for single precision argument
reduction, and more bits to use for double precision argument reduction.