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] |
On 08/23/2016 08:22 PM, Siddhesh Poyarekar wrote:
@@ -181,10 +181,7 @@ do_cos_slow (mynumber u, double x, double dx, double eps, double *corp) cor = cor + ((cs - y) - e1 * x1); res = y + cor; cor = (y - res) + cor; - if (cor > 0) - cor = 1.0005 * cor + eps; - else - cor = 1.0005 * cor - eps; + cor = 1.0005 * cor + ((cor > 0) ? eps : -eps); *corp = cor; return res;
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.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |