This is the mail archive of the libc-alpha@sources.redhat.com 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]

Re: [ballen@uwm.edu] libc/2269: triginometric argument reductionerror in libm



Hi Geoff,

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.

Bruce


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