From 75ff209cbb82e35c84579c9ba631caec95e2c6d0 Mon Sep 17 00:00:00 2001 From: Bruce Evans Date: Thu, 17 Nov 2005 03:53:22 +0000 Subject: [PATCH] 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. --- lib/msun/src/s_cosf.c | 13 ++++++------- lib/msun/src/s_sinf.c | 13 ++++++------- lib/msun/src/s_tanf.c | 19 +++++++++---------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/lib/msun/src/s_cosf.c b/lib/msun/src/s_cosf.c index dd8a759d6a4..3a854b0c26a 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 a2485e81bec..7ddb8b6fa0a 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 81c84e4bc43..70922263571 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)); } }