コード例 #1
0
ファイル: s_cosl.c プロジェクト: AubrCool/glibc
long double __cosl(long double x)
{
	long double y[2],z=0.0;
	int32_t n, se, i0, i1;

    /* High word of x. */
	GET_LDOUBLE_WORDS(se,i0,i1,x);

    /* |x| ~< pi/4 */
	se &= 0x7fff;
	if(se < 0x3ffe || (se == 0x3ffe && i0 <= 0xc90fdaa2))
	  return __kernel_cosl(x,z);

    /* cos(Inf or NaN) is NaN */
	else if (se==0x7fff) {
	  if (i1 == 0 && i0 == 0x80000000)
	    __set_errno (EDOM);
	  return x-x;
	}

    /* argument reduction needed */
	else {
	    n = __ieee754_rem_pio2l(x,y);
	    switch(n&3) {
		case 0: return  __kernel_cosl(y[0],y[1]);
		case 1: return -__kernel_sinl(y[0],y[1],1);
		case 2: return -__kernel_cosl(y[0],y[1]);
		default:
		        return  __kernel_sinl(y[0],y[1],1);
	    }
	}
}
コード例 #2
0
ファイル: s_sinl.c プロジェクト: riscv/riscv-glibc
_Float128 __sinl(_Float128 x)
{
	_Float128 y[2],z=0;
	int64_t n, ix;

    /* High word of x. */
	GET_LDOUBLE_MSW64(ix,x);

    /* |x| ~< pi/4 */
	ix &= 0x7fffffffffffffffLL;
	if(ix <= 0x3ffe921fb54442d1LL)
	  return __kernel_sinl(x,z,0);

    /* sin(Inf or NaN) is NaN */
	else if (ix>=0x7fff000000000000LL) {
	    if (ix == 0x7fff000000000000LL) {
		GET_LDOUBLE_LSW64(n,x);
		if (n == 0)
		    __set_errno (EDOM);
	    }
	    return x-x;
	}

    /* argument reduction needed */
	else {
	    n = __ieee754_rem_pio2l(x,y);
	    switch(n&3) {
		case 0: return  __kernel_sinl(y[0],y[1],1);
		case 1: return  __kernel_cosl(y[0],y[1]);
		case 2: return -__kernel_sinl(y[0],y[1],1);
		default:
			return -__kernel_cosl(y[0],y[1]);
	    }
	}
}
コード例 #3
0
ファイル: s_tanl.c プロジェクト: AubrCool/glibc
long double __tanl(long double x)
{
	long double y[2],z=0.0L;
	int64_t n, ix;

    /* High word of x. */
	GET_LDOUBLE_MSW64(ix,x);

    /* |x| ~< pi/4 */
	ix &= 0x7fffffffffffffffLL;
	if(ix <= 0x3ffe921fb54442d1LL) return __kernel_tanl(x,z,1);

    /* tanl(Inf or NaN) is NaN */
	else if (ix>=0x7fff000000000000LL) {
	    if (ix == 0x7fff000000000000LL) {
		GET_LDOUBLE_LSW64(n,x);
		if (n == 0)
		    __set_errno (EDOM);
	    }
	    return x-x;		/* NaN */
	}

    /* argument reduction needed */
	else {
	    n = __ieee754_rem_pio2l(x,y);
	    return __kernel_tanl(y[0],y[1],1-((n&1)<<1)); /*   1 -- n even
							-1 -- n odd */
	}
}
コード例 #4
0
ファイル: s_tanl.c プロジェクト: AubrCool/glibc
long double __tanl(long double x)
{
	long double y[2],z=0.0;
	int32_t n, se, i0, i1;

    /* High word of x. */
	GET_LDOUBLE_WORDS(se,i0,i1,x);

    /* |x| ~< pi/4 */
	se &= 0x7fff;
	if(se <= 0x3ffe) return __kernel_tanl(x,z,1);

    /* tan(Inf or NaN) is NaN */
	else if (se==0x7fff) {
	  if (i1 == 0 && i0 == 0x80000000)
	    __set_errno (EDOM);
	  return x-x;
	}

    /* argument reduction needed */
	else {
	    n = __ieee754_rem_pio2l(x,y);
	    return __kernel_tanl(y[0],y[1],1-((n&1)<<1)); /*   1 -- n even
							-1 -- n odd */
	}
}
コード例 #5
0
ファイル: s_sincosl.c プロジェクト: 2trill2spill/freebsd
void
sincosl(long double x, long double *sn, long double *cs)
{
	union IEEEl2bits z;
	int e0, sgn;
	long double y[2];

	z.e = x;
	sgn = z.bits.sign;
	z.bits.sign = 0;

	ENTERV();

	/* Optimize the case where x is already within range. */
	if (z.e < M_PI_4) {
		/*
		 * If x = +-0 or x is a subnormal number, then sin(x) = x and
		 * cos(x) = 1.
		 */
		if (z.bits.exp == 0) {
			*sn = x;
			*cs = 1;
		} else
			__kernel_sincosl(x, 0, 0, sn, cs);
		RETURNV();
	}

	/* If x = NaN or Inf, then sin(x) and cos(x) are NaN. */
	if (z.bits.exp == 32767) {
		*sn = x - x;
		*cs = x - x;
		RETURNV();
	}

	/* Range reduction. */
	e0 = __ieee754_rem_pio2l(x, y);

	switch (e0 & 3) {
	case 0:
		__kernel_sincosl(y[0], y[1], 1, sn, cs);
		break;
	case 1:
		__kernel_sincosl(y[0], y[1], 1, cs, sn);
		*cs = -*cs;
		break;
	case 2:
		__kernel_sincosl(y[0], y[1], 1, sn, cs);
		*sn = -*sn;
		*cs = -*cs;
		break;
	default:
		__kernel_sincosl(y[0], y[1], 1, cs, sn);
		*sn = -*sn;
	}

	RETURNV();
}
コード例 #6
0
ファイル: s_sincosl.c プロジェクト: riscv/riscv-glibc
void
__sincosl (long double x, long double *sinx, long double *cosx)
{
  int32_t se, i0, i1 __attribute__ ((unused));

  /* High word of x. */
  GET_LDOUBLE_WORDS (se, i0, i1, x);

  /* |x| ~< pi/4 */
  se &= 0x7fff;
  if (se < 0x3ffe || (se == 0x3ffe && i0 <= 0xc90fdaa2))
    {
      *sinx = __kernel_sinl (x, 0.0, 0);
      *cosx = __kernel_cosl (x, 0.0);
    }
  else if (se == 0x7fff)
    {
      /* sin(Inf or NaN) is NaN */
      *sinx = *cosx = x - x;
      if (isinf (x))
	__set_errno (EDOM);
    }
  else
    {
      /* Argument reduction needed.  */
      long double y[2];
      int n;

      n = __ieee754_rem_pio2l (x, y);
      switch (n & 3)
	{
	case 0:
	  *sinx = __kernel_sinl (y[0], y[1], 1);
	  *cosx = __kernel_cosl (y[0], y[1]);
	  break;
	case 1:
	  *sinx = __kernel_cosl (y[0], y[1]);
	  *cosx = -__kernel_sinl (y[0], y[1], 1);
	  break;
	case 2:
	  *sinx = -__kernel_sinl (y[0], y[1], 1);
	  *cosx = -__kernel_cosl (y[0], y[1]);
	  break;
	default:
	  *sinx = -__kernel_cosl (y[0], y[1]);
	  *cosx = __kernel_sinl (y[0], y[1], 1);
	  break;
	}
    }
}
コード例 #7
0
long double
sinl(long double x)
{
	union IEEEl2bits z;
	int e0, s;
	long double y[2];
	long double hi, lo;

	z.e = x;
	s = z.bits.sign;
	z.bits.sign = 0;

	/* If x = +-0 or x is a subnormal number, then sin(x) = x */
	if (z.bits.exp == 0)
		return (x);

	/* If x = NaN or Inf, then sin(x) = NaN. */
	if (z.bits.exp == 32767)
		return ((x - x) / (x - x));

	ENTERI();

	/* Optimize the case where x is already within range. */
	if (z.e < M_PI_4) {
		hi = __kernel_sinl(z.e, 0, 0);
		RETURNI(s ? -hi : hi);
	}

	e0 = __ieee754_rem_pio2l(x, y);
	hi = y[0];
	lo = y[1];

	switch (e0 & 3) {
	case 0:
	    hi = __kernel_sinl(hi, lo, 1);
	    break;
	case 1:
	    hi = __kernel_cosl(hi, lo);
	    break;
	case 2:
	    hi = - __kernel_sinl(hi, lo, 1);
	    break;
	case 3:
	    hi = - __kernel_cosl(hi, lo);
	    break;
	}
	
	RETURNI(hi);
}
コード例 #8
0
ファイル: s_sincosl.c プロジェクト: siddhesh/glibc
void
__sincosl (_Float128 x, _Float128 *sinx, _Float128 *cosx)
{
  int64_t ix;

  /* High word of x. */
  GET_LDOUBLE_MSW64 (ix, x);

  /* |x| ~< pi/4 */
  ix &= 0x7fffffffffffffffLL;
  if (ix <= 0x3ffe921fb54442d1LL)
    __kernel_sincosl (x, 0, sinx, cosx, 0);
  else if (ix >= 0x7fff000000000000LL)
    {
      /* sin(Inf or NaN) is NaN */
      *sinx = *cosx = x - x;
      if (isinf (x))
	__set_errno (EDOM);
    }
  else
    {
      /* Argument reduction needed.  */
      _Float128 y[2];
      int n;

      n = __ieee754_rem_pio2l (x, y);
      switch (n & 3)
	{
	case 0:
	  __kernel_sincosl (y[0], y[1], sinx, cosx, 1);
	  break;
	case 1:
	  __kernel_sincosl (y[0], y[1], cosx, sinx, 1);
	  *cosx = -*cosx;
	  break;
	case 2:
	  __kernel_sincosl (y[0], y[1], sinx, cosx, 1);
	  *sinx = -*sinx;
	  *cosx = -*cosx;
	  break;
	default:
	  __kernel_sincosl (y[0], y[1], cosx, sinx, 1);
	  *sinx = -*sinx;
	  break;
	}
    }
}
コード例 #9
0
ファイル: s_cosl.c プロジェクト: edgar-pek/PerspicuOS
long double
cosl(long double x)
{
	union IEEEl2bits z;
	int e0;
	long double y[2];
	long double hi, lo;

	z.e = x;
	z.bits.sign = 0;

	/* If x = +-0 or x is a subnormal number, then cos(x) = 1 */
	if (z.bits.exp == 0)
		return (1.0);

	/* If x = NaN or Inf, then cos(x) = NaN. */
	if (z.bits.exp == 32767)
		return ((x - x) / (x - x));

	/* Optimize the case where x is already within range. */
	if (z.e < M_PI_4)
		return (__kernel_cosl(z.e, 0));

	e0 = __ieee754_rem_pio2l(x, y);
	hi = y[0];
	lo = y[1];

	switch (e0 & 3) {
	case 0:
	    hi = __kernel_cosl(hi, lo);
	    break;
	case 1:
	    hi = - __kernel_sinl(hi, lo, 1);
	    break;
	case 2:
	    hi = - __kernel_cosl(hi, lo);
	    break;
	case 3:
	    hi = __kernel_sinl(hi, lo, 1);
	    break;
	}
	
	return (hi);
}
コード例 #10
0
ファイル: s_tanl.c プロジェクト: AhmadTux/freebsd
long double
tanl(long double x)
{
	union IEEEl2bits z;
	int e0, s;
	long double y[2];
	long double hi, lo;

	z.e = x;
	s = z.bits.sign;
	z.bits.sign = 0;

	/* If x = +-0 or x is subnormal, then tan(x) = x. */
	if (z.bits.exp == 0)
		return (x);

	/* If x = NaN or Inf, then tan(x) = NaN. */
	if (z.bits.exp == 32767)
		return ((x - x) / (x - x));

	/* Optimize the case where x is already within range. */
	if (z.e < M_PI_4) {
		hi = __kernel_tanl(z.e, 0, 0);
		return (s ? -hi : hi);
	}

	e0 = __ieee754_rem_pio2l(x, y);
	hi = y[0];
	lo = y[1];

	switch (e0 & 3) {
	case 0:
	case 2:
	    hi = __kernel_tanl(hi, lo, 0);
	    break;
	case 1:
	case 3:
	    hi = __kernel_tanl(hi, lo, 1);
	    break;
	}

	return (hi);
}