This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: weird optimization in sin+cos, x86 backend
On 05/02/2012 19:01, Vincent Lefevre wrote:
> On 2012-02-04 13:00:45 +0100, Andreas Schwab wrote:
>> But it is indistinguishable from 10^22+pi. So both -0.8522008497671888
>> and 0.8522008497671888 are correct results, or anything inbetween.
>
> No, 10^22 and 10^22+pi are different numbers.
Only one of which can be represented in floating point.
So, the gist of the argument is that FP numbers do not represent ranges;
they are a precise but sparse representation of the number line.
It's still not a lot of use doing trig up at the top end of the FP range
where 1 ulp > 2pi. The odds of the value that you wanted to represent
actually being representable are tiny, and hence so are the odds of getting
anything like the result you were hoping for. But, at least identities should
work.
cheers,
DaveK
- References:
- weird optimization in sin+cos, x86 backend
- From: Konstantin Vladimirov
- Re: weird optimization in sin+cos, x86 backend
- Re: weird optimization in sin+cos, x86 backend
- Re: weird optimization in sin+cos, x86 backend
- Re: weird optimization in sin+cos, x86 backend
- Re: weird optimization in sin+cos, x86 backend
- Re: weird optimization in sin+cos, x86 backend
- Re: weird optimization in sin+cos, x86 backend
- From: James Courtier-Dutton
- Re: weird optimization in sin+cos, x86 backend
- Re: weird optimization in sin+cos, x86 backend
- Re: weird optimization in sin+cos, x86 backend