long double sinl(long double x) { union ldshape u = {x}; unsigned n; long double y[2], hi, lo; u.i.se &= 0x7fff; if (u.i.se == 0x7fff) return x - x; if (u.f < M_PI_4) { if (u.i.se < 0x3fff - LDBL_MANT_DIG/2) { /* raise inexact if x!=0 and underflow if subnormal */ FORCE_EVAL(u.i.se == 0 ? x*0x1p-120f : x+0x1p120f); return x; } return __sinl(x, 0.0, 0); } n = __rem_pio2l(x, y); hi = y[0]; lo = y[1]; switch (n & 3) { case 0: return __sinl(hi, lo, 1); case 1: return __cosl(hi, lo); case 2: return -__sinl(hi, lo, 1); case 3: default: return -__cosl(hi, lo); } }
void sincosl(long double x, long double *s, long double *c) { long double y[2], z = 0.0L; int n, ix; ix = *(int *) &x; /* High word of x */ /* |x| ~< pi/4 */ ix &= 0x7fffffff; if (ix <= 0x3ffe9220) *s = __k_sincosl(x, z, c); else if (ix >= 0x7fff0000) *s = *c = x - x; /* trig(Inf or NaN) is NaN */ else { /* argument reduction needed */ n = __rem_pio2l(x, y); switch (n & 3) { case 0: *s = __k_sincosl(y[0], y[1], c); break; case 1: *c = -__k_sincosl(y[0], y[1], s); break; case 2: *s = -__k_sincosl(y[0], y[1], c); *c = -*c; break; case 3: *c = __k_sincosl(y[0], y[1], s); *s = -*s; break; } } }
long double cosl(long double x) { union ldshape u = {x}; unsigned n; long double y[2], hi, lo; u.i.se &= 0x7fff; if (u.i.se == 0x7fff) return x - x; x = u.f; if (x < M_PI_4) { if (u.i.se < 0x3fff - LDBL_MANT_DIG) /* raise inexact if x!=0 */ return 1.0 + x; return __cosl(x, 0); } n = __rem_pio2l(x, y); hi = y[0]; lo = y[1]; switch (n & 3) { case 0: return __cosl(hi, lo); case 1: return -__sinl(hi, lo, 1); case 2: return -__cosl(hi, lo); case 3: default: return __sinl(hi, lo, 1); } }
long double tanl(long double x) { union IEEEl2bits z; long double y[2]; unsigned n; z.e = x; z.bits.sign = 0; /* If x = NaN or Inf, then tan(x) = NaN. */ if (z.bits.exp == 0x7fff) return (x - x) / (x - x); /* |x| < (double)pi/4 */ if (z.e < M_PI_4) { /* |x| < 0x1p-64 */ if (z.bits.exp < 0x3fff - 64) { /* raise inexact if x!=0 and underflow if subnormal */ FORCE_EVAL(z.bits.exp == 0 ? x/0x1p120f : x+0x1p120f); return x; } return __tanl(x, 0, 0); } n = __rem_pio2l(x, y); return __tanl(y[0], y[1], n&1); }
long double sinl(long double x) { long double y[2], z = 0.0L; int n, ix; ix = *(int *) &x; /* High word of x */ ix &= 0x7fffffff; if (ix <= 0x3ffe9220) /* |x| ~< pi/4 */ return (__k_sinl(x, z)); else if (ix >= 0x7fff0000) /* sin(Inf or NaN) is NaN */ return (x - x); else { /* argument reduction needed */ n = __rem_pio2l(x, y); switch (n & 3) { case 0: return (__k_sinl(y[0], y[1])); case 1: return (__k_cosl(y[0], y[1])); case 2: return (-__k_sinl(y[0], y[1])); case 3: return (-__k_cosl(y[0], y[1])); } } /* NOTREACHED */ return 0.0L; }
void sincosl(long double x, long double *sin, long double *cos) { union IEEEl2bits u; unsigned n; long double y[2], s, c; u.e = x; u.bits.sign = 0; /* x = nan or inf */ if (u.bits.exp == 0x7fff) { *sin = *cos = x - x; return; } /* |x| < (double)pi/4 */ if (u.e < M_PI_4) { /* |x| < 0x1p-64 */ if (u.bits.exp < 0x3fff - 64) { /* raise underflow if subnormal */ if (u.bits.exp == 0) FORCE_EVAL(x*0x1p-120f); *sin = x; /* raise inexact if x!=0 */ *cos = 1.0 + x; return; } *sin = __sinl(x, 0, 0); *cos = __cosl(x, 0); return; } n = __rem_pio2l(x, y); s = __sinl(y[0], y[1], 1); c = __cosl(y[0], y[1]); switch (n & 3) { case 0: *sin = s; *cos = c; break; case 1: *sin = c; *cos = -s; break; case 2: *sin = -s; *cos = -c; break; case 3: default: *sin = -c; *cos = s; break; } }
void sincosl(long double x, long double *sin, long double *cos) { union IEEEl2bits u; int n; long double y[2], s, c; u.e = x; u.bits.sign = 0; /* x = +-0 or subnormal */ if (!u.bits.exp) { *sin = x; *cos = 1.0; return; } /* x = nan or inf */ if (u.bits.exp == 0x7fff) { *sin = *cos = x - x; return; } /* |x| < pi/4 */ if (u.e < M_PI_4) { *sin = __sinl(x, 0, 0); *cos = __cosl(x, 0); return; } n = __rem_pio2l(x, y); s = __sinl(y[0], y[1], 1); c = __cosl(y[0], y[1]); switch (n & 3) { case 0: *sin = s; *cos = c; break; case 1: *sin = c; *cos = -s; break; case 2: *sin = -s; *cos = -c; break; case 3: default: *sin = -c; *cos = s; break; } }
long double tanl(long double x) { long double y[2], z = 0.0L; int n, ix; ix = *(int *) &x; /* High word of x */ ix &= 0x7fffffff; if (ix <= 0x3ffe9220) /* |x| ~< pi/4 */ return (__k_tanl(x, z, 0)); else if (ix >= 0x7fff0000) /* trig(Inf or NaN) is NaN */ return (x - x); else { /* argument reduction needed */ n = __rem_pio2l(x, y); return (__k_tanl(y[0], y[1], (n & 1))); } }
void sincosl(long double x, long double *s, long double *c) { long double y[2], z = 0.0L; int n, ix; #if defined(__i386) || defined(__amd64) int *px = (int *) &x; #endif /* trig(Inf or NaN) is NaN */ if (!finitel(x)) { *s = *c = x - x; return; } /* High word of x. */ #if defined(__i386) || defined(__amd64) XTOI(px, ix); #else ix = *(int *) &x; #endif /* |x| ~< pi/4 */ ix &= 0x7fffffff; if (ix <= 0x3ffe9220) *s = __k_sincosl(x, z, c); /* argument reduction needed */ else { n = __rem_pio2l(x, y); switch (n & 3) { case 0: *s = __k_sincosl(y[0], y[1], c); break; case 1: *c = -__k_sincosl(y[0], y[1], s); break; case 2: *s = -__k_sincosl(y[0], y[1], c); *c = -*c; break; case 3: *c = __k_sincosl(y[0], y[1], s); *s = -*s; } } }
long double tanl(long double x) { union ldshape u = {x}; long double y[2]; unsigned n; u.i.se &= 0x7fff; if (u.i.se == 0x7fff) return x - x; if (u.f < M_PI_4) { if (u.i.se < 0x3fff - LDBL_MANT_DIG / 2) { /* raise inexact if x!=0 and underflow if subnormal */ FORCE_EVAL(u.i.se == 0 ? x * 0x1p-120f : x + 0x1p120f); return x; } return __tanl(x, 0, 0); } n = __rem_pio2l(x, y); return __tanl(y[0], y[1], n & 1); }
long double cosl(long double x) { union IEEEl2bits z; unsigned n; long double y[2]; long double hi, lo; z.e = x; z.bits.sign = 0; /* If x = NaN or Inf, then cos(x) = NaN. */ if (z.bits.exp == 0x7fff) return (x - x) / (x - x); /* |x| < (double)pi/4 */ if (z.e < M_PI_4) { /* |x| < 0x1p-64 */ if (z.bits.exp < 0x3fff - 64) /* raise inexact if x!=0 */ return 1.0 + x; return __cosl(z.e, 0); } n = __rem_pio2l(x, y); hi = y[0]; lo = y[1]; switch (n & 3) { case 0: hi = __cosl(hi, lo); break; case 1: hi = -__sinl(hi, lo, 1); break; case 2: hi = -__cosl(hi, lo); break; case 3: hi = __sinl(hi, lo, 1); break; } return hi; }