for the double precision number closest to 2.522464e-1, the glibc sin() function
returns 2.4957989804940914e-01 (when printed to 17 digits, which identifies
uniquely double-precision numbers), whereas the correct rounding to nearest is
According to glibc/sysdeps/ieee754/dbl-64/s_sin.c, the result should be
always correctly rounded.
Created attachment 4236 [details]
compile with -fno-builtin to ensure the sin() call is not folded at
This bug is analyzed and a fix is proposed at
In short, it suffices to replace the line:
return (res==res+1.025*cor)? res : slow1(x);
in file glibc/sysdeps/ieee754/dbl-64/s_sin.c by:
return (res==res+1.096*cor)? res : slow1(x);
(In reply to comment #3)
First, the patch contains unrelated changes.
Second, on what basis is this magic new factor chosen? If this is just empirical, why should I trust that value?
(In reply to comment #4)
> Second, on what basis is this magic new factor chosen?
see the pdf at comment #2.
Created attachment 5854 [details]
Patch for sine
I send the wrong patch to the mailing list, have attached now the proper one.
I checked in the patch.