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.
This commit is contained in:
Bruce Evans 2005-11-17 03:53:22 +00:00
parent 990634f5e8
commit 75ff209cbb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=152540
3 changed files with 21 additions and 24 deletions

View file

@ -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 */

View file

@ -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 */

View file

@ -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));
}
}