12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- #include <sys/cdefs.h>
- #include <float.h>
- #include "openlibm.h"
- #include "math_private.h"
- static const double
- s1pio2 = 1*M_PI_2,
- s2pio2 = 2*M_PI_2,
- s3pio2 = 3*M_PI_2,
- s4pio2 = 4*M_PI_2;
- float
- sinf(float x)
- {
- double y;
- int32_t n, hx, ix;
- GET_FLOAT_WORD(hx,x);
- ix = hx & 0x7fffffff;
- if(ix <= 0x3f490fda) {
- if(ix<0x39800000)
- if(((int)x)==0) return x;
- return __kernel_sindf(x);
- }
- if(ix<=0x407b53d1) {
- if(ix<=0x4016cbe3) {
- if(hx>0)
- return __kernel_cosdf(x - s1pio2);
- else
- return -__kernel_cosdf(x + s1pio2);
- } else
- return __kernel_sindf((hx > 0 ? s2pio2 : -s2pio2) - x);
- }
- if(ix<=0x40e231d5) {
- if(ix<=0x40afeddf) {
- if(hx>0)
- return -__kernel_cosdf(x - s3pio2);
- else
- return __kernel_cosdf(x + s3pio2);
- } else
- return __kernel_sindf(x + (hx > 0 ? -s4pio2 : s4pio2));
- }
-
- else if (ix>=0x7f800000) return x-x;
-
- else {
- n = __ieee754_rem_pio2f(x,&y);
- switch(n&3) {
- case 0: return __kernel_sindf(y);
- case 1: return __kernel_cosdf(y);
- case 2: return __kernel_sindf(-y);
- default:
- return -__kernel_cosdf(y);
- }
- }
- }
|