cosf.c revision 25c28e83beb90e7c80452a7c818c5e6f73a07dc8
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* See sincosf.c
*/
#include "libm.h"
extern const int _TBL_ipio2_inf[];
extern int __rem_pio2m(double *, double *, int, int, int, const int *);
extern int __swapRP(int);
#endif
static const double C[] = {
1.85735322054308378716204874632872525989806770558e-0003,
-1.95035094218403635082921458859320791358115801259e-0004,
5.38400550766074785970952495168558701485841707252e+0002,
-3.31975110777873728964197739157371509422022905947e+0001,
1.09349482127188401868272000389539985058873853699e-0003,
-5.03324285989964979398034700054920226866107675091e-0004,
2.43792880266971107750418061559602239831538067410e-0005,
9.14499072605666582228127405245558035523741471271e+0002,
-3.63151270591815439197122504991683846785293207730e+0001,
0.636619772367581343075535, /* 2^ -1 * 1.45F306DC9C883 */
0.5,
1.570796326734125614166, /* 2^ 0 * 1.921FB54400000 */
6.077100506506192601475e-11, /* 2^-34 * 1.0B4611A626331 */
};
#define S0 C[0]
#define S1 C[1]
#define S2 C[2]
#define S3 C[3]
#define C0 C[4]
#define C1 C[5]
#define C2 C[6]
#define C3 C[7]
#define C4 C[8]
#define invpio2 C[9]
#define half C[10]
#define pio2_1 C[11]
#define pio2_t C[12]
float
cosf(float x)
{
double y, z, w;
float f;
volatile int i;
hx = *((int *)&x);
y = (double)x;
i = (int)y;
#ifdef lint
i = i;
#endif
return (1.0f);
}
z = y * y;
} else if (hx > 0) {
z = y * y;
} else {
z = y * y;
}
int rp;
#endif
w = y * invpio2;
if (hx < 0)
n = (int)(w - half);
else
n = (int)(w + half);
n++;
if (rp != fp_extended)
#endif
} else {
if (ix >= 0x7f800000)
return (x / x); /* cos(Inf or NaN) is NaN */
}
if (n & 1) {
/* compute cos y */
z = y * y;
} else {
/* compute sin y */
z = y * y;
}
return ((n & 2)? -f : f);
}