本文整理匯總了C++中GET_FLOAT_WORD函數的典型用法代碼示例。如果您正苦於以下問題:C++ GET_FLOAT_WORD函數的具體用法?C++ GET_FLOAT_WORD怎麽用?C++ GET_FLOAT_WORD使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GET_FLOAT_WORD函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: acosf
float
acosf(float x)
{
float z,p,q,r,w,s,c,df;
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix==0x3f800000) { /* |x|==1 */
if(hx>0) return 0.0; /* acos(1) = 0 */
else return pi+(float)2.0*pio2_lo; /* acos(-1)= pi */
} else if(ix>0x3f800000) { /* |x| >= 1 */
return (x-x)/(x-x); /* acos(|x|>1) is NaN */
}
if(ix<0x3f000000) { /* |x| < 0.5 */
if(ix<=0x23000000) return pio2_hi+pio2_lo;/*if|x|<2**-57*/
z = x*x;
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
r = p/q;
return pio2_hi - (x - (pio2_lo-x*r));
} else if (hx<0) { /* x < -0.5 */
z = (one+x)*(float)0.5;
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
s = sqrtf(z);
r = p/q;
w = r*s-pio2_lo;
return pi - (float)2.0*(s+w);
} else { /* x > 0.5 */
int32_t idf;
z = (one-x)*(float)0.5;
s = sqrtf(z);
df = s;
GET_FLOAT_WORD(idf,df);
SET_FLOAT_WORD(df,idf&0xfffff000);
c = (z-df*df)/(s+df);
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
r = p/q;
w = r*s+c;
return (float)2.0*(df+w);
}
}
示例2: frexpf
float
frexpf(float x, int *eptr)
{
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = 0x7fffffff&hx;
*eptr = 0;
if(ix>=0x7f800000||(ix==0)) return x; /* 0,inf,nan */
if (ix<0x00800000) { /* subnormal */
x *= two25;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
*eptr = -25;
}
*eptr += (ix>>23)-126;
hx = (hx&0x807fffff)|0x3f000000;
*(int*)(void*)&x = hx;
return x;
}
示例3: __erff
float __erff(float x)
{
int32_t hx,ix,i;
float R,S,P,Q,s,y,z,r;
GET_FLOAT_WORD(hx,x);
ix = hx&0x7fffffff;
if(ix>=0x7f800000) { /* erf(nan)=nan */
i = ((u_int32_t)hx>>31)<<1;
return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */
}
示例4: __ieee754_y0f
float
__ieee754_y0f(float x)
{
float z, s,c,ss,cc,u,v;
int32_t hx,ix;
GET_FLOAT_WORD(hx,x);
ix = 0x7fffffff&hx;
/* Y0(NaN) is NaN, y0(-inf) is Nan, y0(inf) is 0 */
if(ix>=0x7f800000) return one/(x+x*x);
if(ix==0) return -one/zero;
if(hx<0) return zero/zero;
if(ix >= 0x40000000) { /* |x| >= 2.0 */
/* y0(x) = sqrt(2/(pi*x))*(p0(x)*sin(x0)+q0(x)*cos(x0))
* where x0 = x-pi/4
* Better formula:
* cos(x0) = cos(x)cos(pi/4)+sin(x)sin(pi/4)
* = 1/sqrt(2) * (sin(x) + cos(x))
* sin(x0) = sin(x)cos(3pi/4)-cos(x)sin(3pi/4)
* = 1/sqrt(2) * (sin(x) - cos(x))
* To avoid cancellation, use
* sin(x) +- cos(x) = -cos(2x)/(sin(x) -+ cos(x))
* to compute the worse one.
*/
s = sinf(x);
c = cosf(x);
ss = s-c;
cc = s+c;
/*
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
*/
if(ix<0x7f000000) { /* make sure x+x not overflow */
z = -cosf(x+x);
if ((s*c)<zero) cc = z/ss;
else ss = z/cc;
}
#ifdef DEAD_CODE
if(ix>0x80000000) z = (invsqrtpi*ss)/sqrtf(x);
else
#endif
{
u = pzerof(x); v = qzerof(x);
z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
}
return z;
}
if(ix<=0x32000000) { /* x < 2**-27 */
return(u00 + tpi*__ieee754_logf(x));
}
z = x*x;
u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
v = one+z*(v01+z*(v02+z*(v03+z*v04)));
return(u/v + tpi*(__ieee754_j0f(x)*__ieee754_logf(x)));
}
示例5: cosf
float cosf(float x) {
double y;
uint32_t ix;
unsigned n, sign;
GET_FLOAT_WORD(ix, x);
sign = ix >> 31;
ix &= 0x7fffffff;
if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
if (ix < 0x39800000) { /* |x| < 2**-12 */
/* raise inexact if x != 0 */
FORCE_EVAL(x + 0x1p120f);
return 1.0f;
}
return __cosdf(x);
}
if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
if (ix > 0x4016cbe3) /* |x| ~> 3*pi/4 */
return -__cosdf(sign ? x + c2pio2 : x - c2pio2);
else {
if (sign)
return __sindf(x + c1pio2);
else
return __sindf(c1pio2 - x);
}
}
if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
if (ix > 0x40afeddf) /* |x| ~> 7*pi/4 */
return __cosdf(sign ? x + c4pio2 : x - c4pio2);
else {
if (sign)
return __sindf(-x - c3pio2);
else
return __sindf(x - c3pio2);
}
}
/* cos(Inf or NaN) is NaN */
if (ix >= 0x7f800000)
return x - x;
/* general argument reduction needed */
n = __rem_pio2f(x, &y);
switch (n & 3) {
case 0:
return __cosdf(y);
case 1:
return __sindf(-y);
case 2:
return -__cosdf(y);
default:
return __sindf(y);
}
}
示例6: remainderf
float remainderf(float x, float p)
{
int32_t hx,hp;
uint32_t sx;
float p_half;
GET_FLOAT_WORD(hx, x);
GET_FLOAT_WORD(hp, p);
sx = hx & 0x80000000;
hp &= 0x7fffffff;
hx &= 0x7fffffff;
/* purge off exception values */
if (hp == 0 || hx >= 0x7f800000 || hp > 0x7f800000) /* p = 0, x not finite, p is NaN */
return (x*p)/(x*p);
if (hp <= 0x7effffff)
x = fmodf(x, p + p); /* now x < 2p */
if (hx - hp == 0)
return 0.0f*x;
x = fabsf(x);
p = fabsf(p);
if (hp < 0x01000000) {
if (x + x > p) {
x -= p;
if (x + x >= p)
x -= p;
}
} else {
p_half = 0.5f*p;
if (x > p_half) {
x -= p;
if (x >= p_half)
x -= p;
}
}
GET_FLOAT_WORD(hx, x);
if ((hx & 0x7fffffff) == 0)
hx = 0;
SET_FLOAT_WORD(x, hx ^ sx);
return x;
}
示例7: __fpclassifyf
/*
* On the SPU, single precision floating point returns only FP_NORMAL and
* FP_ZERO, since FP_NAN, FP_INFINITE, and FP_SUBNORMAL are not
* supported, base on the common f_fpclassify.c.
*/
int
__fpclassifyf (float x)
{
__uint32_t w;
GET_FLOAT_WORD(w,x);
if (w == 0x00000000 || w == 0x80000000)
return FP_ZERO;
return FP_NORMAL;
}
示例8: atanf
float atanf(float x)
{
float_t w,s1,s2,z;
uint32_t ix,sign;
int id;
GET_FLOAT_WORD(ix, x);
sign = ix>>31;
ix &= 0x7fffffff;
if (ix >= 0x4c800000) { /* if |x| >= 2**26 */
if (isnan(x))
return x;
z = atanhi[3] + 0x1p-120f;
return sign ? -z : z;
}
if (ix < 0x3ee00000) { /* |x| < 0.4375 */
if (ix < 0x39800000) { /* |x| < 2**-12 */
if (ix < 0x00800000)
/* raise underflow for subnormal x */
FORCE_EVAL(x*x);
return x;
}
id = -1;
} else {
x = fabsf(x);
if (ix < 0x3f980000) { /* |x| < 1.1875 */
if (ix < 0x3f300000) { /* 7/16 <= |x| < 11/16 */
id = 0;
x = (2.0f*x - 1.0f)/(2.0f + x);
} else { /* 11/16 <= |x| < 19/16 */
id = 1;
x = (x - 1.0f)/(x + 1.0f);
}
} else {
if (ix < 0x401c0000) { /* |x| < 2.4375 */
id = 2;
x = (x - 1.5f)/(1.0f + 1.5f*x);
} else { /* 2.4375 <= |x| < 2**26 */
id = 3;
x = -1.0f/x;
}
}
}
/* end of argument reduction */
z = x*x;
w = z*z;
/* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
s1 = z*(aT[0]+w*(aT[2]+w*aT[4]));
s2 = w*(aT[1]+w*aT[3]);
if (id < 0)
return x - x*(s1+s2);
z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
return sign ? -z : z;
}
示例9: isposf
int isposf(float x)
{
__int32_t wx;
GET_FLOAT_WORD(wx, x);
if (wx & 0x80000000)
return (0);
else
return (1);
}
示例10: nextafterf
float nextafterf(float x, float y) {
int32_t hx, hy, ix, iy;
GET_FLOAT_WORD(hx, x);
GET_FLOAT_WORD(hy, y);
ix = hx & 0x7fffffff; /* |x| */
iy = hy & 0x7fffffff; /* |y| */
/* x is nan or y is nan? */
if ((ix > 0x7f800000) || (iy > 0x7f800000))
return x + y;
if (x == y)
return y;
if (ix == 0) { /* x == 0? */
SET_FLOAT_WORD(x, (hy & 0x80000000) | 1);
return x;
}
if (hx >= 0) { /* x > 0 */
if (hx > hy) { /* x > y: x -= ulp */
hx -= 1;
} else { /* x < y: x += ulp */
hx += 1;
}
} else { /* x < 0 */
if (hy >= 0 || hx > hy) { /* x < y: x -= ulp */
hx -= 1;
} else { /* x > y: x += ulp */
hx += 1;
}
}
hy = hx & 0x7f800000;
if (hy >= 0x7f800000) {
x = x + x; /* overflow */
return x; /* overflow */
}
SET_FLOAT_WORD(x, hx);
return x;
}
示例11: __ieee754_remainderf
float
__ieee754_remainderf(float x, float p)
{
int32_t hx,hp;
u_int32_t sx;
float p_half;
GET_FLOAT_WORD(hx,x);
GET_FLOAT_WORD(hp,p);
sx = hx&0x80000000;
hp &= 0x7fffffff;
hx &= 0x7fffffff;
/* purge off exception values */
if((hp==0)|| /* p = 0 */
(hx>=0x7f800000)|| /* x not finite */
((hp>0x7f800000))) /* p is NaN */
return nan_mix_op(x, p, *)/nan_mix_op(x, p, *);
if (hp<=0x7effffff) x = __ieee754_fmodf(x,p+p); /* now x < 2p */
if ((hx-hp)==0) return zero*x;
x = fabsf(x);
p = fabsf(p);
if (hp<0x01000000) {
if(x+x>p) {
x-=p;
if(x+x>=p) x -= p;
}
} else {
p_half = (float)0.5*p;
if(x>p_half) {
x-=p;
if(x>=p_half) x -= p;
}
}
GET_FLOAT_WORD(hx,x);
if ((hx&0x7fffffff)==0) hx = 0;
SET_FLOAT_WORD(x,hx^sx);
return x;
}
示例12: atanf
float atanf(float x)
{
float w,s1,s2,z;
int32_t ix,hx,id;
GET_FLOAT_WORD(hx, x);
ix = hx & 0x7fffffff;
if (ix >= 0x4c800000) { /* if |x| >= 2**26 */
if (ix > 0x7f800000) /* NaN */
return x+x;
if (hx > 0)
return atanhi[3] + *(volatile float *)&atanlo[3];
else
return -atanhi[3] - *(volatile float *)&atanlo[3];
}
if (ix < 0x3ee00000) { /* |x| < 0.4375 */
if (ix < 0x39800000) { /* |x| < 2**-12 */
/* raise inexact */
if(huge+x>1.0f)
return x;
}
id = -1;
} else {
x = fabsf(x);
if (ix < 0x3f980000) { /* |x| < 1.1875 */
if (ix < 0x3f300000) { /* 7/16 <= |x| < 11/16 */
id = 0;
x = (2.0f*x - 1.0f)/(2.0f + x);
} else { /* 11/16 <= |x| < 19/16 */
id = 1;
x = (x - 1.0f)/(x + 1.0f);
}
} else {
if (ix < 0x401c0000) { /* |x| < 2.4375 */
id = 2;
x = (x - 1.5f)/(1.0f + 1.5f*x);
} else { /* 2.4375 <= |x| < 2**26 */
id = 3;
x = -1.0f/x;
}
}
}
/* end of argument reduction */
z = x*x;
w = z*z;
/* break sum from i=0 to 10 aT[i]z**(i+1) into odd and even poly */
s1 = z*(aT[0]+w*(aT[2]+w*aT[4]));
s2 = w*(aT[1]+w*aT[3]);
if (id < 0)
return x - x*(s1+s2);
z = atanhi[id] - ((x*(s1+s2) - atanlo[id]) - x);
return hx < 0 ? -z : z;
}
示例13: cosf
float
cosf(float x)
{
float y[2];
int32_t n, hx, ix;
GET_FLOAT_WORD(hx,x);
ix = hx & 0x7fffffff;
if(ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
if(ix<0x39800000) /* |x| < 2**-12 */
if(((int)x)==0) return 1.0; /* 1 with inexact if x != 0 */
return __kernel_cosdf(x);
}
if(ix<=0x407b53d1) { /* |x| ~<= 5*pi/4 */
if(ix>0x4016cbe3) /* |x| ~> 3*pi/4 */
return -__kernel_cosdf(x + (hx > 0 ? -c2pio2 : c2pio2));
else {
if(hx>0)
return __kernel_sindf(c1pio2 - x);
else
return __kernel_sindf(x + c1pio2);
}
}
if(ix<=0x40e231d5) { /* |x| ~<= 9*pi/4 */
if(ix>0x40afeddf) /* |x| ~> 7*pi/4 */
return __kernel_cosdf(x + (hx > 0 ? -c4pio2 : c4pio2));
else {
if(hx>0)
return __kernel_sindf(x - c3pio2);
else
return __kernel_sindf(-c3pio2 - x);
}
}
/* cos(Inf or NaN) is NaN */
else if (ix>=0x7f800000) return x-x;
/* general argument reduction needed */
else {
n = __ieee754_rem_pio2f(x,y);
switch(n&3) {
case 0:
return __kernel_cosdf((double)y[0]+y[1]);
case 1:
return __kernel_sindf(-(double)y[0]-y[1]);
case 2:
return -__kernel_cosdf((double)y[0]+y[1]);
default:
return __kernel_sindf((double)y[0]+y[1]);
}
}
}
示例14: j0f
float j0f(float x)
{
float z, s,c,ss,cc,r,u,v;
int32_t hx,ix;
GET_FLOAT_WORD(hx, x);
ix = hx & 0x7fffffff;
if (ix >= 0x7f800000)
return 1.0f/(x*x);
x = fabsf(x);
if (ix >= 0x40000000) { /* |x| >= 2.0 */
s = sinf(x);
c = cosf(x);
ss = s-c;
cc = s+c;
if (ix < 0x7f000000) { /* make sure x+x does not overflow */
z = -cosf(x+x);
if (s*c < 0.0f)
cc = z/ss;
else
ss = z/cc;
}
/*
* j0(x) = 1/sqrt(pi) * (P(0,x)*cc - Q(0,x)*ss) / sqrt(x)
* y0(x) = 1/sqrt(pi) * (P(0,x)*ss + Q(0,x)*cc) / sqrt(x)
*/
if (ix > 0x80000000)
z = (invsqrtpi*cc)/sqrtf(x);
else {
u = pzerof(x);
v = qzerof(x);
z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
}
return z;
}
if (ix < 0x39000000) { /* |x| < 2**-13 */
/* raise inexact if x != 0 */
if (huge+x > 1.0f) {
if (ix < 0x32000000) /* |x| < 2**-27 */
return 1.0f;
return 1.0f - 0.25f*x*x;
}
}
z = x*x;
r = z*(R02+z*(R03+z*(R04+z*R05)));
s = 1.0f+z*(S01+z*(S02+z*(S03+z*S04)));
if(ix < 0x3F800000) { /* |x| < 1.00 */
return 1.0f + z*(-0.25f + (r/s));
} else {
u = 0.5f*x;
return (1.0f+u)*(1.0f-u) + z*(r/s);
}
}
示例15: logbf
float
logbf(float x)
{
int32_t ix;
GET_FLOAT_WORD(ix,x);
ix &= 0x7fffffff; /* high |x| */
if(ix==0) return (float)-1.0/fabsf(x);
if(ix>=0x7f800000) return x*x;
if((ix>>=23)==0) /* IEEE 754 logb */
return -126.0;
else
return (float) (ix-127);