This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: floating point inconsistency


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]