예제 #1
0
long double
__floorl (long double x)
{
  double xh, xl, hi, lo;

  ldbl_unpack (x, &xh, &xl);

  /* Return Inf, Nan, +/-0 unchanged.  */
  if (__builtin_expect (xh != 0.0
			&& __builtin_isless (__builtin_fabs (xh),
					     __builtin_inf ()), 1))
    {
      hi = __floor (xh);
      if (hi != xh)
	{
	  /* The high part is not an integer; the low part does not
	     affect the result.  */
	  xh = hi;
	  xl = 0;
	}
      else
	{
	  /* The high part is a nonzero integer.  */
	  lo = __floor (xl);
	  xh = hi;
	  xl = lo;
	  ldbl_canonicalize_int (&xh, &xl);
	}
    }

  return ldbl_pack (xh, xl);
}
예제 #2
0
파일: s_modf.c 프로젝트: AubrCool/glibc
double
__modf (double x, double *iptr)
{
  if (__builtin_isinf (x))
    {
      *iptr = x;
      return __copysign (0.0, x);
    }
  else if (__builtin_isnan (x))
    {
      *iptr = NAN;
      return NAN;
    }

  if (x >= 0.0)
    {
      *iptr = __floor (x);
      return __copysign (x - *iptr, x);
    }
  else
    {
      *iptr = __ceil (x);
      return __copysign (x - *iptr, x);
    }
}
예제 #3
0
__declspec ( naked ) void nseel_asm_floor(void)
{
  FUNC1_ENTER

  *__nextBlock = __floor(*parm_a);

  FUNC_LEAVE
}
예제 #4
0
파일: e_lgamma_r.c 프로젝트: AubrCool/glibc
static double
sin_pi(double x)
{
	double y,z;
	int n,ix;

	GET_HIGH_WORD(ix,x);
	ix &= 0x7fffffff;

	if(ix<0x3fd00000) return __sin(pi*x);
	y = -x;		/* x is assume negative */

    /*
     * argument reduction, make sure inexact flag not raised if input
     * is an integer
     */
	z = __floor(y);
	if(z!=y) {				/* inexact anyway */
	    y  *= 0.5;
	    y   = 2.0*(y - __floor(y));		/* y = |x| mod 2.0 */
	    n   = (int) (y*4.0);
	} else {
	    if(ix>=0x43400000) {
		y = zero; n = 0;                 /* y must be even */
	    } else {
		if(ix<0x43300000) z = y+two52;	/* exact */
		GET_LOW_WORD(n,z);
		n &= 1;
		y  = n;
		n<<= 2;
	    }
	}
	switch (n) {
	    case 0:   y =  __sin(pi*y); break;
	    case 1:
	    case 2:   y =  __cos(pi*(0.5-y)); break;
	    case 3:
	    case 4:   y =  __sin(pi*(one-y)); break;
	    case 5:
	    case 6:   y = -__cos(pi*(y-1.5)); break;
	    default:  y =  __sin(pi*(y-2.0)); break;
	    }
	return -y;
}
예제 #5
0
파일: w_lgamma_r.c 프로젝트: imbaqian/glibc
double
__lgamma_r(double x, int *signgamp)
{
    double y = __ieee754_lgamma_r(x,signgamp);
    if(__builtin_expect(!__finite(y), 0)
            && __finite(x) && _LIB_VERSION != _IEEE_)
        return __kernel_standard(x, x,
                                 __floor(x)==x&&x<=0.0
                                 ? 15 /* lgamma pole */
                                 : 14); /* lgamma overflow */

    return y;
}
예제 #6
0
int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int32_t *ipio2)
{
	int32_t jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
	double z,fw,f[20],fq[20],q[20];

    /* initialize jk*/
	jk = init_jk[prec];
	jp = jk;

    /* determine jx,jv,q0, note that 3>q0 */
	jx =  nx-1;
	jv = (e0-3)/24; if(jv<0) jv=0;
	q0 =  e0-24*(jv+1);

    /* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
	j = jv-jx; m = jx+jk;
	for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j];

    /* compute q[0],q[1],...q[jk] */
	for (i=0;i<=jk;i++) {
	    for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
	}

	jz = jk;
recompute:
    /* distill q[] into iq[] reversingly */
	for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
	    fw    =  (double)((int32_t)(twon24* z));
	    iq[i] =  (int32_t)(z-two24*fw);
	    z     =  q[j-1]+fw;
	}

    /* compute n */
	z  = __scalbn(z,q0);		/* actual value of z */
	z -= 8.0*__floor(z*0.125);		/* trim off integer >= 8 */
	n  = (int32_t) z;
	z -= (double)n;
	ih = 0;
	if(q0>0) {	/* need iq[jz-1] to determine n */
	    i  = (iq[jz-1]>>(24-q0)); n += i;
	    iq[jz-1] -= i<<(24-q0);
	    ih = iq[jz-1]>>(23-q0);
	}
예제 #7
0
파일: w_lgamma.c 프로젝트: AdvancedC/glibc
double
__lgamma(double x)
{
	int local_signgam = 0;
	double y = __ieee754_lgamma_r(x,
				      _LIB_VERSION != _ISOC_
				      /* ISO C99 does not define the
					 global variable.  */
				      ? &signgam
				      : &local_signgam);
	if(__builtin_expect(!__finite(y), 0)
	   && __finite(x) && _LIB_VERSION != _IEEE_)
		return __kernel_standard(x, x,
					 __floor(x)==x&&x<=0.0
					 ? 15 /* lgamma pole */
					 : 14); /* lgamma overflow */

	return y;
}
예제 #8
0
double
__tgamma(double x)
{
	int local_signgam;
	double y = __ieee754_gamma_r(x,&local_signgam);

	if(__glibc_unlikely (!isfinite (y) || y == 0)
	   && (isfinite (x) || (isinf (x) && x < 0.0))
	   && _LIB_VERSION != _IEEE_) {
	  if (x == 0.0)
	    return __kernel_standard(x,x,50); /* tgamma pole */
	  else if(__floor(x)==x&&x<0.0)
	    return __kernel_standard(x,x,41); /* tgamma domain */
	  else if (y == 0)
	    __set_errno (ERANGE); /* tgamma underflow */
	  else
	    return __kernel_standard(x,x,40); /* tgamma overflow */
	}
	return local_signgam < 0 ? -y : y;
}
예제 #9
0
long double
__floorl(long double x)
{
	return ( (long double)__floor((double)x) );
}
예제 #10
0
파일: mathcalls.c 프로젝트: fidian/MathLib
Err mathlib_floor(UInt16 refnum, double x, double *result) {
#pragma unused(refnum)
	*result = __floor(x);
	return mlErrNone;
}