projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
include/ifaddrs.h: add prototypes for get/freeifaddrs
[musl]
/
src
/
math
/
atanf.c
diff --git
a/src/math/atanf.c
b/src/math/atanf.c
index
8c2b46b
..
4b59509
100644
(file)
--- a/
src/math/atanf.c
+++ b/
src/math/atanf.c
@@
-38,30
+38,26
@@
static const float aT[] = {
6.1687607318e-02,
};
6.1687607318e-02,
};
-static const float
-one = 1.0,
-huge = 1.0e30;
-
float atanf(float x)
{
float w,s1,s2,z;
float atanf(float x)
{
float w,s1,s2,z;
- int32_t ix,hx,id;
+ uint32_t ix,sign;
+ int id;
- GET_FLOAT_WORD(hx, x);
- ix = hx & 0x7fffffff;
+ GET_FLOAT_WORD(ix, x);
+ sign = ix>>31;
+ ix &= 0x7fffffff;
if (ix >= 0x4c800000) { /* if |x| >= 2**26 */
if (ix >= 0x4c800000) { /* if |x| >= 2**26 */
- if (ix > 0x7f800000) /* NaN */
- return x+x;
- if (hx > 0)
- return atanhi[3] + *(volatile float *)&atanlo[3];
- else
- return -atanhi[3] - *(volatile float *)&atanlo[3];
+ if (isnan(x))
+ return x;
+ z = atanhi[3] + 0x1p-120f;
+ return sign ? -z : z;
}
if (ix < 0x3ee00000) { /* |x| < 0.4375 */
if (ix < 0x39800000) { /* |x| < 2**-12 */
}
if (ix < 0x3ee00000) { /* |x| < 0.4375 */
if (ix < 0x39800000) { /* |x| < 2**-12 */
- /* raise inexact */
- if(huge+x>one)
-
return x;
+ /* raise inexact
if x!=0
*/
+ FORCE_EVAL(x + 0x1p120f);
+ return x;
}
id = -1;
} else {
}
id = -1;
} else {
@@
-69,18
+65,18
@@
float atanf(float x)
if (ix < 0x3f980000) { /* |x| < 1.1875 */
if (ix < 0x3f300000) { /* 7/16 <= |x| < 11/16 */
id = 0;
if (ix < 0x3f980000) { /* |x| < 1.1875 */
if (ix < 0x3f300000) { /* 7/16 <= |x| < 11/16 */
id = 0;
- x = (
(float)2.0*x-one)/((float)2.0+
x);
+ x = (
2.0f*x - 1.0f)/(2.0f +
x);
} else { /* 11/16 <= |x| < 19/16 */
id = 1;
} else { /* 11/16 <= |x| < 19/16 */
id = 1;
- x = (x
-one)/(x+one
);
+ x = (x
- 1.0f)/(x + 1.0f
);
}
} else {
if (ix < 0x401c0000) { /* |x| < 2.4375 */
id = 2;
}
} else {
if (ix < 0x401c0000) { /* |x| < 2.4375 */
id = 2;
- x = (x
-(float)1.5)/(one+(float)1.5
*x);
+ x = (x
- 1.5f)/(1.0f + 1.5f
*x);
} else { /* 2.4375 <= |x| < 2**26 */
id = 3;
} else { /* 2.4375 <= |x| < 2**26 */
id = 3;
- x = -
(float)1.0
/x;
+ x = -
1.0f
/x;
}
}
}
}
}
}
@@
-93,5
+89,5
@@
float atanf(float x)
if (id < 0)
return x - x*(s1+s2);
z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
if (id < 0)
return x - x*(s1+s2);
z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
- return
hx < 0
? -z : z;
+ return
sign
? -z : z;
}
}