floating point inconsistency

Tim Prince n8tm@aol.com
Tue Feb 16 14:39:00 GMT 2010


On 2/16/2010 4:20 AM, Christoph Groth wrote:
> I can avoid this inconsistency while staying
> portable by computing cos(x) as sqrt(1 - sin(x)^2).
>
>    
As you are concerned about low order bits (and, you say, portability), 
and you said you wished to avoid 387 functions,
double tmp = sin(x);
.... sqrt((1+tmp)*(1-tmp))...
would be more often accurate.
I haven't heard of satisfactory solution of the question of SSE2 math 
functions for glibc, but that goes further off topic.

-- 
Tim Prince



More information about the Gcc-help mailing list