This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: [PATCH 2/5] Use fabs(x) instead of branching on signedness of input to sin and cos


On Tue, 23 Aug 2016, Manfred wrote:

> If eps is known to be >=0 then
> > +  cor = 1.0005 * cor + ((cor > 0) ? eps : -eps);
> might be written as
> cor = 1.0005 * cor + copysign(eps, cor);
> 
> Similarly to fabs(), copysign() avoids a branch - or a potential one from the
> ternary.

That should be __copysign for namespace reasons (though they should 
generally do the same thing because of inlines in math_private.h).

-- 
Joseph S. Myers
joseph@codesourcery.com


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