Hi, On Thu, 9 Feb 2012, James Courtier-Dutton wrote:
> Results when compiled for 32bit x86. > gcc -m32 -g -O0 -c -o sincos1.o sincos1.c > gcc -m32 -static -g -o sincos1 sincos1.o -lm > > ./sincos1 > sin = 4.62613040764601746e-01 > sinl = 0.46261304076460176 > sincos = 4.62613040764601746e-01 > sincosl = 0.46261304076460176 > > Which are all inaccurate. Because all use hardware on x86, with unpatched glibc, not the software implementation. Only on x86_64 at least the sin() implementation uses a software implementation while sincos (l or not) and sinl uses hardware. I think that was said multiple times already. > So, we have a case of the same program compiled for 32bit might give > different floating point results than the same source compiled for > 64bit. > > From what I can tell, the xmm register instructions on x86_64 are using > 128bit precision which probably explains why the result is more > accurate. That's not the reason, no. The reason is that the reduction step of the software implementation is more accurate. And it is so because it uses a higher precision representation of pi, for long double a 22512 bit long representation. The hardware fprem simply is not as accurate. Ciao, Michael.