Print this page
11210 libm should be cstyle(1ONBLD) clean
@@ -20,10 +20,11 @@
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -78,12 +79,11 @@
*/
#include "libm.h"
extern const long double _TBL_atanl_hi[], _TBL_atanl_lo[];
-static const long double
- one = 1.0L,
+static const long double one = 1.0L,
p1 = -3.333333333333333333333333333331344526118e-0001L,
p2 = 1.999999999999999999999999989931277668570e-0001L,
p3 = -1.428571428571428571428553606221309530901e-0001L,
p4 = 1.111111111111111111095219842737139747418e-0001L,
p5 = -9.090909090909090825503603835248061123323e-0002L,
@@ -107,13 +107,14 @@
#define i0 0
#define i1 3
long double
-atanl(long double x) {
+atanl(long double x)
+{
long double y, z, r, p, s;
- int *px = (int *) &x, *py = (int *) &y;
+ int *px = (int *)&x, *py = (int *)&y;
int ix, iy, sign, j;
ix = px[i0];
sign = ix & 0x80000000;
ix ^= sign;
@@ -121,47 +122,53 @@
/* for |x| < 1/8 */
if (ix < 0x3ffc0000) {
if (ix < 0x3feb0000) { /* when |x| < 2**(-prec/6-2) */
if (ix < 0x3fc50000) { /* if |x| < 2**(-prec/2-2) */
s = one;
- *(3 - i0 + (int *) &s) = -1; /* s = 1-ulp */
- *(1 + (int *) &s) = -1;
- *(2 + (int *) &s) = -1;
- *(i0 + (int *) &s) -= 1;
- if ((int) (s * x) < 1)
+ *(3 - i0 + (int *)&s) = -1; /* s = 1-ulp */
+ *(1 + (int *)&s) = -1;
+ *(2 + (int *)&s) = -1;
+ *(i0 + (int *)&s) -= 1;
+
+ if ((int)(s * x) < 1)
return (x); /* raise inexact */
}
+
z = x * x;
- if (ix < 0x3fe20000) { /* if |x| < 2**(-prec/4-1) */
+
+ if (ix < 0x3fe20000) /* if |x| < 2**(-prec/4-1) */
return (x + (x * z) * p1);
- } else { /* if |x| < 2**(-prec/6-2) */
+ else /* if |x| < 2**(-prec/6-2) */
return (x + (x * z) * (p1 + z * p2));
}
- }
+
z = x * x;
- return (x + (x * z) * (p1 + z * (p2 + z * (p3 + z * (p4 +
- z * (p5 + z * (p6 + z * (p7 + z * (p8 + z * (p9 +
- z * (p10 + z * (p11 + z * (p12 + z * p13)))))))))))));
+ return (x + (x * z) * (p1 + z * (p2 + z * (p3 + z * (p4 + z *
+ (p5 + z * (p6 + z * (p7 + z * (p8 + z * (p9 + z *
+ (p10 + z * (p11 + z * (p12 + z * p13)))))))))))));
}
/* for |x| >= 8.0 */
if (ix >= 0x40020000) {
px[i0] = ix;
+
if (ix < 0x40050400) { /* x < 65 */
r = one / x;
z = r * r;
+
/*
* poly1
*/
- y = r * (one + z * (p1 + z * (p2 + z * (p3 +
- z * (p4 + z * (p5 + z * (p6 + z * (p7 +
- z * (p8 + z * (p9 + z * (p10 + z * (p11 +
- z * (p12 + z * p13)))))))))))));
+ y = r * (one + z * (p1 + z * (p2 + z * (p3 + z * (p4 +
+ z * (p5 + z * (p6 + z * (p7 + z * (p8 + z * (p9 +
+ z * (p10 + z * (p11 + z * (p12 + z *
+ p13)))))))))))));
y -= pio2lo;
} else if (ix < 0x40260000) { /* x < 2**(prec/3+2) */
r = one / x;
z = r * r;
+
/*
* poly2
*/
y = r * (one + z * (q1 + z * (q2 + z * (q3 + z * (q4 +
z * (q5 + z * (q6 + z * q7)))))));
@@ -171,10 +178,11 @@
} else if (ix < 0x7fff0000) { /* x < inf */
y = -pio2lo;
} else { /* x is inf or NaN */
if (((ix - 0x7fff0000) | px[1] | px[2] | px[i1]) != 0)
return (x - x);
+
y = -pio2lo;
}
if (sign == 0)
return (pio2hi - y);
@@ -191,16 +199,19 @@
if (sign == 0)
s = (x - y) / (one + x * y);
else
s = (y - x) / (one + x * y);
+
z = s * s;
+
if (ix == iy)
p = s * (one + z * (q1 + z * (q2 + z * (q3 + z * q4))));
else
- p = s * (one + z * (q1 + z * (q2 + z * (q3 + z * (q4 +
- z * (q5 + z * (q6 + z * q7)))))));
+ p = s * (one + z * (q1 + z * (q2 + z * (q3 + z * (q4 + z * (q5 +
+ z * (q6 + z * q7)))))));
+
if (sign == 0) {
r = p + _TBL_atanl_lo[j];
return (r + _TBL_atanl_hi[j]);
} else {
r = p - _TBL_atanl_lo[j];