On 2010-03-21 16:14:49 +0100, Aurelien Jarno wrote: > On Wed, Mar 17, 2010 at 11:29:00AM +0100, Vincent Lefevre wrote: > > It may be optimized, but completely buggy. For instance, on 1e22, > > sincos returns 0.46261304076460174617 for the sine instead of > > -0.85220084976718879499 (correctly rounded value). Even the sign > > is incorrect! > > Where did you get this result? In my tests both the x87 FPU and the > current glibc code give the following result when using double variables > and the sincos() function: > > sin (1e22) = 0.46261304076460174617 > cos (1e22) = -0.88656030506363692201
Actually the sincos() function uses the x87 FPU (fsincos instruction), so that's not surprising that you get the same result. Try with GCC >= 4.4 (so that constant expressions are evaluated with MPFR): xvii:~> cat tst.c #include <stdio.h> #include <math.h> int main (void) { printf ("sin (1e22) = %.17g\n", sin(1e22)); printf ("cos (1e22) = %.17g\n", cos(1e22)); return 0; } xvii:~> gcc tst.c -o tst xvii:~> ./tst sin (1e22) = -0.85220084976718879 cos (1e22) = 0.52321478539513899 And if you don't trust MPFR, you can still try with gp (pari). -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <http://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon) -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org