summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2005-11-17 03:53:22 +0000
committerbde <bde@FreeBSD.org>2005-11-17 03:53:22 +0000
commit5fa674913848bccaaf6b269105472b89eb8b525f (patch)
tree7074eb754428937cca1af6914608724e7230a756 /lib
parent7c337042bec10f155ea78bd9c9ef213c54b95847 (diff)
downloadFreeBSD-src-5fa674913848bccaaf6b269105472b89eb8b525f.zip
FreeBSD-src-5fa674913848bccaaf6b269105472b89eb8b525f.tar.gz
Minor cleanups:
s_cosf.c and s_sinf.c: Use a non-bogus magic constant for the threshold of pi/4. It was 2 ulps smaller than pi/4 rounded down, but its value is not critical so it should be the result of natural rounding. s_cosf.c and s_tanf.c: Use a literal 0.0 instead of an unnecessary variable initialized to [(float)]0.0. Let the function prototype convert to 0.0F. Improved wording in some comments. Attempted to improve indentation of comments.
Diffstat (limited to 'lib')
-rw-r--r--lib/msun/src/s_cosf.c13
-rw-r--r--lib/msun/src/s_sinf.c13
-rw-r--r--lib/msun/src/s_tanf.c19
3 files changed, 21 insertions, 24 deletions
diff --git a/lib/msun/src/s_cosf.c b/lib/msun/src/s_cosf.c
index dd8a759..3a854b0 100644
--- a/lib/msun/src/s_cosf.c
+++ b/lib/msun/src/s_cosf.c
@@ -23,17 +23,16 @@ static char rcsid[] = "$FreeBSD$";
float
cosf(float x)
{
- float y[2],z=0.0;
+ float y[2];
int32_t n,ix;
GET_FLOAT_WORD(ix,x);
-
- /* |x| ~< pi/4 */
ix &= 0x7fffffff;
- if(ix <= 0x3f490fd8) {
- if(ix<0x39800000) /* if x < 2**-12 */
- if(((int)x)==0) return 1.0; /* generate inexact */
- return __kernel_cosf(x,z);
+
+ if(ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
+ if(ix<0x39800000) /* |x| < 2**-12 */
+ if(((int)x)==0) return 1.0; /* 1 with inexact if x != 0 */
+ return __kernel_cosf(x,0.0);
}
/* cos(Inf or NaN) is NaN */
diff --git a/lib/msun/src/s_sinf.c b/lib/msun/src/s_sinf.c
index a2485e8..7ddb8b6 100644
--- a/lib/msun/src/s_sinf.c
+++ b/lib/msun/src/s_sinf.c
@@ -23,17 +23,16 @@ static char rcsid[] = "$FreeBSD$";
float
sinf(float x)
{
- float y[2],z=0.0;
+ float y[2];
int32_t n, ix;
GET_FLOAT_WORD(ix,x);
-
- /* |x| ~< pi/4 */
ix &= 0x7fffffff;
- if(ix <= 0x3f490fd8) {
- if(ix<0x39800000) /* if x < 2**-12 */
- if(((int)x)==0) return x; /* generate inexact */
- return __kernel_sinf(x,z,0);
+
+ if(ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
+ if(ix<0x39800000) /* |x| < 2**-12 */
+ if(((int)x)==0) return x; /* x with inexact if x != 0 */
+ return __kernel_sinf(x,0.0,0);
}
/* sin(Inf or NaN) is NaN */
diff --git a/lib/msun/src/s_tanf.c b/lib/msun/src/s_tanf.c
index 81c84e4..7092226 100644
--- a/lib/msun/src/s_tanf.c
+++ b/lib/msun/src/s_tanf.c
@@ -23,26 +23,25 @@ static char rcsid[] = "$FreeBSD$";
float
tanf(float x)
{
- float y[2],z=0.0;
+ float y[2];
int32_t n, ix;
GET_FLOAT_WORD(ix,x);
-
- /* |x| ~< pi/4 */
ix &= 0x7fffffff;
- if(ix <= 0x3f490fda) {
- if(ix<0x39800000) /* |x| < 2**-12 */
- if(((int)x)==0) return x; /* generate inexact */
- return __kernel_tanf(x,z,1);
+
+ if(ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
+ if(ix<0x39800000) /* |x| < 2**-12 */
+ if(((int)x)==0) return x; /* x with inexact if x != 0 */
+ return __kernel_tanf(x,0.0,1);
}
/* tan(Inf or NaN) is NaN */
- else if (ix>=0x7f800000) return x-x; /* NaN */
+ else if (ix>=0x7f800000) return x-x;
/* argument reduction needed */
else {
n = __ieee754_rem_pio2f(x,y);
- return __kernel_tanf(y[0],y[1],1-((n&1)<<1)); /* 1 -- n even
- -1 -- n odd */
+ /* integer parameter: 1 -- n even; -1 -- n odd */
+ return __kernel_tanf(y[0],y[1],1-((n&1)<<1));
}
}
OpenPOWER on IntegriCloud