This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Sine and Cosine Accuracy
Scott Robert Ladd writes:
> chris jefferson wrote:
> > I would like to say yes, I disagree that this should be true. By your
> > argument, why isn't sin(pow(2.0,90.0)+1) == sin(6.153104..)? Also, how
> > the heck do you intend to actually calculate that value? You can't just
> > keep subtracting multiples of 2*pi from pow(2.0, 90.0) else nothing will
> > happen, and if you choose to subtract some large multiple of 2*pi, your
> > answer wouldn't end up accurate to anywhere near that many decimal
> > places. Floating point numbers approximate real numbers, and at the size
> > you are considering, the approximation contains values for which sin(x)
> > takes all values in the range [-1,1].
>
> Nonsense.
>
> Show me an example where the following function should *not* print the
> same values for a and b:
>
> void same_sines(double x)
> {
> double a = sin(x);
> double b = sin(fmod(x, 2.0 * PI));
> printf("%20.15f,%20.15f\n",a,b);
> }
Please! Every correct implementation of libm will not print the same
result for these two values, because it is necessary to do the range
reduction in extended precision.
Andrew.