예제 #1
0
long double cosl(long double x)
{
	long double y[2],z=0.0L;
	int n;

    /* |x| ~< pi/4 */
        if(x >= -0.7853981633974483096156608458198757210492 &&
           x <= 0.7853981633974483096156608458198757210492)
          return kernel_cosl(x, z);

    /* sinl(Inf or NaN) is NaN, sinl(0) is 0 */
        else if ((x + x == x && x != 0.0) || x != x)
          return x-x;           /* NaN */

    /* 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
파일: tanl.c 프로젝트: FEI17N/gnulib
long double
tanl (long double x)
{
  long double y[2], z = 0.0L;
  int n;

  /* tanl(NaN) is NaN */
  if (isnanl (x))
    return x;

  /* |x| ~< pi/4 */
  if (x >= -0.7853981633974483096156608458198757210492 &&
      x <= 0.7853981633974483096156608458198757210492)
    return kernel_tanl (x, z, 1);

  /* tanl(Inf) is NaN, tanl(0) is 0 */
  else if (x + x == x)
    return x - x;               /* NaN */

  /* argument reduction needed */
  else
    {
      n = ieee754_rem_pio2l (x, y);
      /* 1 -- n even, -1 -- n odd */
      return kernel_tanl (y[0], y[1], 1 - ((n & 1) << 1));
    }
}