math cleanup: use 1.0f instead of (float)1.0
authornsz <nsz@port70.net>
Tue, 13 Mar 2012 19:24:23 +0000 (20:24 +0100)
committernsz <nsz@port70.net>
Tue, 13 Mar 2012 19:24:23 +0000 (20:24 +0100)
25 files changed:
src/math/__log1pf.h
src/math/acosf.c
src/math/acoshf.c
src/math/asinf.c
src/math/asinhf.c
src/math/atan2f.c
src/math/atanf.c
src/math/atanhf.c
src/math/ceilf.c
src/math/erff.c
src/math/expf.c
src/math/expm1f.c
src/math/floorf.c
src/math/j0f.c
src/math/j1f.c
src/math/jnf.c
src/math/lgammaf_r.c
src/math/log10f.c
src/math/log1pf.c
src/math/log2f.c
src/math/logf.c
src/math/powf.c
src/math/remainderf.c
src/math/scalbf.c
src/math/sinhf.c

index 110acecbe8dc99fe3eba9a4e197eda9699578b96..99492c5a1ac9b892628d79b61f38df37eb1a85de 100644 (file)
@@ -24,12 +24,12 @@ static inline float __log1pf(float f)
 {
        float hfsq,s,z,R,w,t1,t2;
 
-       s = f/((float)2.0+f);
+       s = f/(2.0f + f);
        z = s*s;
        w = z*z;
        t1 = w*(Lg2+w*Lg4);
        t2 = z*(Lg1+w*Lg3);
        R = t2+t1;
-       hfsq = (float)0.5*f*f;
+       hfsq = 0.5f * f * f;
        return s*(hfsq+R);
 }
index dd3bba29e31cf212c73c7a175d3bc0ca5b1679ee..b4665d02179cf6933c793e71d0042ad9d4ad9eba 100644 (file)
@@ -36,8 +36,8 @@ float acosf(float x)
        ix = hx & 0x7fffffff;
        if (ix >= 0x3f800000) {  /* |x| >= 1 */
                if (ix == 0x3f800000) {  /* |x| == 1 */
-                       if(hx>0) return 0.0;  /* acos(1) = 0 */
-                       return pi + (float)2.0*pio2_lo;  /* acos(-1)= pi */
+                       if (hx > 0) return 0.0f;  /* acos(1) = 0 */
+                       return pi + 2.0f*pio2_lo;  /* acos(-1)= pi */
                }
                return (x-x)/(x-x);  /* acos(|x|>1) is NaN */
        }
@@ -50,17 +50,17 @@ float acosf(float x)
                r = p/q;
                return pio2_hi - (x - (pio2_lo-x*r));
        } else if (hx < 0) {     /* x < -0.5 */
-               z = (one+x)*(float)0.5;
+               z = (one+x)*0.5f;
                p = z*(pS0+z*(pS1+z*pS2));
                q = one+z*qS1;
                s = sqrtf(z);
                r = p/q;
                w = r*s-pio2_lo;
-               return pi - (float)2.0*(s+w);
+               return pi - 2.0f*(s+w);
        } else {                 /* x > 0.5 */
                int32_t idf;
 
-               z = (one-x)*(float)0.5;
+               z = (one-x)*0.5f;
                s = sqrtf(z);
                df = s;
                GET_FLOAT_WORD(idf,df);
@@ -70,6 +70,6 @@ float acosf(float x)
                q = one+z*qS1;
                r = p/q;
                w = r*s+c;
-               return (float)2.0*(df+w);
+               return 2.0f*(df+w);
        }
 }
index 30a3a943142fcbcfc29cc7315ab2a890072c6460..57ce5cb8297e0bb88caa375bb269be2ad5ee5cdb 100644 (file)
@@ -35,9 +35,9 @@ float acoshf(float x)
                return 0.0;  /* acosh(1) = 0 */
        } else if (hx > 0x40000000) {  /* 2**28 > x > 2 */
                t = x*x;
-               return logf((float)2.0*x - one/(x+sqrtf(t-one)));
+               return logf(2.0f*x - one/(x+sqrtf(t-one)));
        } else {                /* 1 < x < 2 */
                t = x-one;
-               return log1pf(t + sqrtf((float)2.0*t+t*t));
+               return log1pf(t + sqrtf(2.0f*t+t*t));
        }
 }
index 729dd37fdb75eac0e487ff81807639bd8b120737..7865a45bef7c18edce6c71912dc70c65f0149904 100644 (file)
@@ -52,7 +52,7 @@ float asinf(float x)
        }
        /* 1 > |x| >= 0.5 */
        w = one - fabsf(x);
-       t = w*(float)0.5;
+       t = w*0.5f;
        p = t*(pS0+t*(pS1+t*pS2));
        q = one+t*qS1;
        s = sqrt(t);
index 5f4bb39cf2f9364a1ac5ebd9c4a2fadf99ce7076..cb6e5b89b8496b0d4c2d78c2afb732f0257e512e 100644 (file)
@@ -38,7 +38,7 @@ float asinhf(float x)
                w = logf(fabsf(x)) + ln2;
        } else if (ix > 0x40000000) {  /* 2**28 > |x| > 2.0 */
                t = fabsf(x);
-               w = logf((float)2.0*t + one/(sqrtf(x*x+one)+t));
+               w = logf(2.0f*t + one/(sqrtf(x*x+one)+t));
        } else {                /* 2.0 > |x| > 2**-28 */
                t = x*x;
                w =log1pf(fabsf(x) + t/(one+sqrtf(one+t)));
index 4d78840be3ec31043dabe05d718a3ca25b36682a..b6a7f92d6d10e7f8dd69a8796a1ac8167b12b696 100644 (file)
@@ -58,8 +58,8 @@ float atan2f(float y, float x)
                        switch (m) {
                        case 0: return  pi_o_4+tiny; /* atan(+INF,+INF) */
                        case 1: return -pi_o_4-tiny; /* atan(-INF,+INF) */
-                       case 2: return (float)3.0*pi_o_4+tiny;  /*atan(+INF,-INF)*/
-                       case 3: return (float)-3.0*pi_o_4-tiny; /*atan(-INF,-INF)*/
+                       case 2: return 3.0f*pi_o_4+tiny;  /*atan(+INF,-INF)*/
+                       case 3: return -3.0f*pi_o_4-tiny; /*atan(-INF,-INF)*/
                        }
                } else {
                        switch (m) {
@@ -77,7 +77,7 @@ float atan2f(float y, float x)
        /* compute y/x */
        k = (iy-ix)>>23;
        if (k > 26) {                  /* |y/x| >  2**26 */
-               z = pi_o_2+(float)0.5*pi_lo;
+               z = pi_o_2 + 0.5f*pi_lo;
                m &= 1;
        } else if (k < -26 && hx < 0)  /* 0 > |y|/x > -2**-26 */
                z = 0.0;
index 8c2b46b0dba964ebdc318e7815c719c1cda10656..73cebb5e92fc07810b17569b078ba3a96aedece0 100644 (file)
@@ -69,18 +69,18 @@ float atanf(float x)
                if (ix < 0x3f980000) {  /* |x| < 1.1875 */
                        if (ix < 0x3f300000) {  /*  7/16 <= |x| < 11/16 */
                                id = 0;
-                               x = ((float)2.0*x-one)/((float)2.0+x);
+                               x = (2.0f*x - one)/(2.0f + x);
                        } else {                /* 11/16 <= |x| < 19/16 */
                                id = 1;
-                               x = (x-one)/(x+one);
+                               x = (x - one)/(x + one);
                        }
                } else {
                        if (ix < 0x401c0000) {  /* |x| < 2.4375 */
                                id = 2;
-                               x = (x-(float)1.5)/(one+(float)1.5*x);
+                               x = (x - 1.5f)/(one + 1.5f*x);
                        } else {                /* 2.4375 <= |x| < 2**26 */
                                id = 3;
-                               x = -(float)1.0/x;
+                               x = -1.0f/x;
                        }
                }
        }
index 2efbd79c9ef89fe6bf1511eaa09b03296be890ec..9c65dc7fbaa3d05f045abe4ef30b208c3783268d 100644 (file)
@@ -34,9 +34,9 @@ float atanhf(float x)
        SET_FLOAT_WORD(x, ix);
        if (ix < 0x3f000000) {                 /* x < 0.5 */
                t = x+x;
-               t = (float)0.5*log1pf(t + t*x/(one-x));
+               t = 0.5f*log1pf(t + t*x/(one-x));
        } else
-               t = (float)0.5*log1pf((x+x)/(one-x));
+               t = 0.5f*log1pf((x+x)/(one-x));
        if (hx >= 0)
                return t;
        return -t;
index d83066a574affac18ce9fc9c90c9dee5f71c6e7a..d22688a7b917865dd5f9d4b443bd1f89c430f36c 100644 (file)
@@ -27,7 +27,7 @@ float ceilf(float x)
        if (j0 < 23) {
                if (j0 < 0) {
                        /* raise inexact if x != 0 */
-                       if (huge+x > (float)0.0) {
+                       if (huge+x > 0.0f) {
                                /* return 0*sign(x) if |x|<1 */
                                if (i0 < 0)
                                        i0 = 0x80000000;
@@ -39,7 +39,7 @@ float ceilf(float x)
                        if ((i0&i) == 0)
                                return x; /* x is integral */
                        /* raise inexact flag */
-                       if (huge+x > (float)0.0) {
+                       if (huge+x > 0.0f) {
                                if (i0 > 0)
                                        i0 += 0x00800000>>j0;
                                i0 &= ~i;
index e4e353d7eabcc2795c088117c6993cfbd55df779..eef4851eeb30dec7c0e3288f1a294a2812dddddd 100644 (file)
@@ -106,7 +106,7 @@ float erff(float x)
                if (ix < 0x31800000) {  /* |x| < 2**-28 */
                        if (ix < 0x04000000)
                                /*avoid underflow */
-                               return (float)0.125*((float)8.0*x+efx8*x);
+                               return 0.125f*(8.0f*x + efx8*x);
                        return x + efx*x;
                }
                z = x*x;
@@ -143,7 +143,7 @@ float erff(float x)
        }
        GET_FLOAT_WORD(ix, x);
        SET_FLOAT_WORD(z, ix&0xfffff000);
-       r = expf(-z*z - (float)0.5625) * expf((z-x)*(z+x) + R/S);
+       r = expf(-z*z - 0.5625f) * expf((z-x)*(z+x) + R/S);
        if (hx >= 0)
                return one - r/x;
        return  r/x - one;
@@ -206,7 +206,7 @@ float erfcf(float x)
                }
                GET_FLOAT_WORD(ix, x);
                SET_FLOAT_WORD(z, ix&0xfffff000);
-               r = expf(-z*z - (float)0.5625) * expf((z-x)*(z+x) + R/S);
+               r = expf(-z*z - 0.5625f) * expf((z-x)*(z+x) + R/S);
                if (hx > 0)
                        return r/x;
                return two - r/x;
index a0eaa7a7ea15af737351b4c8d372f48f8a6c44ec..8925a6f1edd628f870a375f77348a5cc59d45f5f 100644 (file)
@@ -85,11 +85,11 @@ float expf(float x)
                SET_FLOAT_WORD(twopk, 0x3f800000+((k+100)<<23));
        c  = x - t*(P1+t*P2);
        if (k == 0)
-               return one - ((x*c)/(c-(float)2.0)-x);
-       y = one - ((lo-(x*c)/((float)2.0-c))-hi);
+               return one - ((x*c)/(c - 2.0f) - x);
+       y = one - ((lo - (x*c)/(2.0f - c)) - hi);
        if (k < -125)
                return y*twopk*twom100;
        if (k == 128)
-               return y*2.0F*0x1p127F;
+               return y*2.0f*0x1p127f;
        return y*twopk;
 }
index cfab6975a7dbe4024cb2f3d70b3612bd097d4870..a8b79e881fc8a9daecd7af735e5a3a9ade9e19d5 100644 (file)
@@ -53,7 +53,7 @@ float expm1f(float x)
                }
                if (xsb != 0) {  /* x < -27*ln2 */
                        /* raise inexact */
-                       if (x+tiny < (float)0.0)
+                       if (x+tiny < 0.0f)
                                return tiny-one;  /* return -1 */
                }
        }
@@ -71,7 +71,7 @@ float expm1f(float x)
                                k = -1;
                        }
                } else {
-                       k  = invln2*x+((xsb==0)?(float)0.5:(float)-0.5);
+                       k  = invln2*x + (xsb==0 ? 0.5f : -0.5f);
                        t  = k;
                        hi = x - t*ln2_hi;      /* t*ln2_hi is exact here */
                        lo = t*ln2_lo;
@@ -85,27 +85,27 @@ float expm1f(float x)
                k = 0;
 
        /* x is now in primary range */
-       hfx = (float)0.5*x;
+       hfx = 0.5f*x;
        hxs = x*hfx;
        r1 = one+hxs*(Q1+hxs*Q2);
-       t  = (float)3.0 - r1*hfx;
-       e  = hxs*((r1-t)/((float)6.0 - x*t));
+       t  = 3.0f - r1*hfx;
+       e  = hxs*((r1-t)/(6.0f - x*t));
        if (k == 0)  /* c is 0 */
                return x - (x*e-hxs);
        SET_FLOAT_WORD(twopk, 0x3f800000+(k<<23));   /* 2^k */
        e  = x*(e-c) - c;
        e -= hxs;
        if (k == -1)
-               return (float)0.5*(x-e) - (float)0.5;
+               return 0.5f*(x-e) - 0.5f;
        if (k == 1) {
-               if (x < (float)-0.25)
-                       return -(float)2.0*(e-(x+(float)0.5));
-               return one+(float)2.0*(x-e);
+               if (x < -0.25f)
+                       return -2.0f*(e-(x+0.5f));
+               return one + 2.0f*(x-e);
        }
        if (k <= -2 || k > 56) {   /* suffice to return exp(x)-1 */
                y = one - (e - x);
                if (k == 128)
-                       y = y*2.0F*0x1p127F;
+                       y = y*2.0f*0x1p127f;
                else
                        y = y*twopk;
                return y - one;
@@ -116,7 +116,7 @@ float expm1f(float x)
                y = t - (e - x);
                y = y*twopk;
        } else {
-               SET_FLOAT_WORD(t, ((0x7f-k)<<23));  /* 2^-k */
+               SET_FLOAT_WORD(t, (0x7f-k)<<23);  /* 2^-k */
                y = x - (e + t);
                y += one;
                y = y*twopk;
index 958abf5bd8c150c8121827bf8a8f3c97811561d2..23fa5e7d56949feb6b3b4935da3e95a96362048e 100644 (file)
@@ -36,7 +36,7 @@ float floorf(float x)
        if (j0 < 23) {
                if (j0 < 0) {  /* |x| < 1 */
                        /* raise inexact if x != 0 */
-                       if (huge+x > (float)0.0) {
+                       if (huge+x > 0.0f) {
                                if (i0 >= 0)  /* x >= 0 */
                                        i0 = 0;
                                else if ((i0&0x7fffffff) != 0)
@@ -47,7 +47,7 @@ float floorf(float x)
                        if ((i0&i) == 0)
                                return x; /* x is integral */
                        /* raise inexact flag */
-                       if (huge+x > (float)0.0) {
+                       if (huge+x > 0.0f) {
                                if (i0 < 0)
                                        i0 += 0x00800000>>j0;
                                i0 &= ~i;
index 77a2d73481ebcabaf824bc07ffdfec5888903693..52cb0ab41a238c58956cd89f036b0f32f532b6d5 100644 (file)
@@ -74,16 +74,16 @@ float j0f(float x)
                if (huge+x > one) {
                        if (ix < 0x32000000)  /* |x| < 2**-27 */
                                return one;
-                       return one - (float)0.25*x*x;
+                       return one - 0.25f*x*x;
                }
        }
        z = x*x;
        r =  z*(R02+z*(R03+z*(R04+z*R05)));
        s =  one+z*(S01+z*(S02+z*(S03+z*S04)));
        if(ix < 0x3F800000) {   /* |x| < 1.00 */
-               return one + z*((float)-0.25+(r/s));
+               return one + z*(-0.25f + (r/s));
        } else {
-               u = (float)0.5*x;
+               u = 0.5f*x;
                return (one+u)*(one-u) + z*(r/s);
        }
 }
@@ -343,5 +343,5 @@ static float qzerof(float x)
        z = one/(x*x);
        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
-       return (-(float).125 + r/s)/x;
+       return (-.125f + r/s)/x;
 }
index 0323ec7828bb97244ea1d34fa35f23016fe0f960..2d617b67d235f5060fa00f65cbfa1f768b623efd 100644 (file)
@@ -75,13 +75,13 @@ float j1f(float x)
        if (ix < 0x32000000) {  /* |x| < 2**-27 */
                /* raise inexact if x!=0 */
                if (huge+x > one)
-                       return (float)0.5*x;
+                       return 0.5f*x;
        }
        z = x*x;
        r = z*(r00+z*(r01+z*(r02+z*r03)));
        s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
        r *= x;
-       return x*(float)0.5 + r/s;
+       return 0.5f*x + r/s;
 }
 
 static const float U0[5] = {
@@ -338,5 +338,5 @@ static float qonef(float x)
        z = one/(x*x);
        r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
        s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
-       return ((float).375 + r/s)/x;
+       return (.375f + r/s)/x;
 }
index 7db93ae7056aeca4db06c9c54f5fedfc922d240e..648db32b57350ab0101b7593de8d3446c8935bba 100644 (file)
@@ -64,7 +64,7 @@ float jnf(int n, float x)
                        if (n > 33)  /* underflow */
                                b = zero;
                        else {
-                               temp = x*(float)0.5;
+                               temp = 0.5f * x;
                                b = temp;
                                for (a=one,i=2; i<=n; i++) {
                                        a *= (float)i;    /* a = n! */
@@ -106,13 +106,13 @@ float jnf(int n, float x)
                        float q0,q1,h,tmp;
                        int32_t k,m;
 
-                       w = (n+n)/(float)x;
-                       h = (float)2.0/(float)x;
+                       w = (n+n)/x;
+                       h = 2.0f/x;
                        z = w+h;
                        q0 = w;
-                       q1 = w*z - (float)1.0;
+                       q1 = w*z - 1.0f;
                        k = 1;
-                       while (q1 < (float)1.0e9) {
+                       while (q1 < 1.0e9f) {
                                k += 1;
                                z += h;
                                tmp = z*q1 - q0;
@@ -135,7 +135,7 @@ float jnf(int n, float x)
                        tmp = n;
                        v = two/x;
                        tmp = tmp*logf(fabsf(v*tmp));
-                       if (tmp < (float)8.8721679688e+01) {
+                       if (tmp < 88.721679688f) {
                                for (i=n-1,di=(float)(i+i); i>0; i--) {
                                        temp = b;
                                        b *= di;
@@ -151,7 +151,7 @@ float jnf(int n, float x)
                                        a = temp;
                                        di -= two;
                                        /* scale b to avoid spurious overflow */
-                                       if (b > (float)1e10) {
+                                       if (b > 1e10f) {
                                                a /= b;
                                                t /= b;
                                                b = one;
index 9955b2f93f1d07a2adb2bcc1aa0bdf0fa0825f32..c6280f5be41d509202f34a8d9a19243ed55e6f89 100644 (file)
@@ -104,9 +104,9 @@ static float sin_pif(float x)
         */
        z = floorf(y);
        if (z != y) {   /* inexact anyway */
-               y *= (float)0.5;
-               y  = (float)2.0*(y - floorf(y));   /* y = |x| mod 2.0 */
-               n  = (int) (y*(float)4.0);
+               y *= 0.5f;
+               y  = 2.0f*(y - floorf(y));   /* y = |x| mod 2.0 */
+               n  = (int)(y*4.0f);
        } else {
                if (ix >= 0x4b800000) {
                        y = zero;  /* y must be even */
@@ -123,12 +123,12 @@ static float sin_pif(float x)
        switch (n) {
        case 0:  y =  __sindf(pi*y); break;
        case 1:
-       case 2:  y =  __cosdf(pi*((float)0.5-y)); break;
+       case 2:  y =  __cosdf(pi*(0.5f - y)); break;
        case 3:
-       case 4:  y =  __sindf(pi*(one-y)); break;
+       case 4:  y =  __sindf(pi*(one - y)); break;
        case 5:
-       case 6:  y = -__cosdf(pi*(y-(float)1.5)); break;
-       default: y =  __sindf(pi*(y-(float)2.0)); break;
+       case 6:  y = -__cosdf(pi*(y - 1.5f)); break;
+       default: y =  __sindf(pi*(y - 2.0f)); break;
        }
        return -y;
 }
@@ -188,7 +188,7 @@ float lgammaf_r(float x, int *signgamp)
                } else {
                        r = zero;
                        if (ix >= 0x3fdda618) {  /* [1.7316,2] */
-                               y = (float)2.0 - x;
+                               y = 2.0f - x;
                                i = 0;
                        } else if (ix >= 0x3F9da620) {  /* [1.23,1.73] */
                                y = x - tc;
@@ -204,7 +204,7 @@ float lgammaf_r(float x, int *signgamp)
                        p1 = a0+z*(a2+z*(a4+z*(a6+z*(a8+z*a10))));
                        p2 = z*(a1+z*(a3+z*(a5+z*(a7+z*(a9+z*a11)))));
                        p = y*p1+p2;
-                       r += (p-(float)0.5*y);
+                       r += p - 0.5f*y;
                        break;
                case 1:
                        z = y*y;
@@ -218,21 +218,21 @@ float lgammaf_r(float x, int *signgamp)
                case 2:
                        p1 = y*(u0+y*(u1+y*(u2+y*(u3+y*(u4+y*u5)))));
                        p2 = one+y*(v1+y*(v2+y*(v3+y*(v4+y*v5))));
-                       r += (-(float)0.5*y + p1/p2);
+                       r += -0.5f*y + p1/p2;
                }
        } else if (ix < 0x41000000) {  /* x < 8.0 */
                i = (int)x;
-               y = x-(float)i;
+               y = x - (float)i;
                p = y*(s0+y*(s1+y*(s2+y*(s3+y*(s4+y*(s5+y*s6))))));
                q = one+y*(r1+y*(r2+y*(r3+y*(r4+y*(r5+y*r6)))));
                r = half*y+p/q;
                z = one;    /* lgamma(1+s) = log(s) + lgamma(s) */
                switch (i) {
-               case 7: z *= y + (float)6.0;  /* FALLTHRU */
-               case 6: z *= y + (float)5.0;  /* FALLTHRU */
-               case 5: z *= y + (float)4.0;  /* FALLTHRU */
-               case 4: z *= y + (float)3.0;  /* FALLTHRU */
-               case 3: z *= y + (float)2.0;  /* FALLTHRU */
+               case 7: z *= y + 6.0f;  /* FALLTHRU */
+               case 6: z *= y + 5.0f;  /* FALLTHRU */
+               case 5: z *= y + 4.0f;  /* FALLTHRU */
+               case 4: z *= y + 3.0f;  /* FALLTHRU */
+               case 3: z *= y + 2.0f;  /* FALLTHRU */
                        r += logf(z);
                        break;
                }
index 4175cce289de7304bfceb81cf4661b21259184d8..7e4ac9a8c80bb82443130c055700eff05342fae5 100644 (file)
@@ -53,8 +53,8 @@ float log10f(float x)
        SET_FLOAT_WORD(x, hx|(i^0x3f800000));  /* normalize x or x/2 */
        k += i>>23;
        y = (float)k;
-       f = x - (float)1.0;
-       hfsq = (float)0.5*f*f;
+       f = x - 1.0f;
+       hfsq = 0.5f * f * f;
        r = __log1pf(f);
 
 // FIXME
index 5c718152e9535ccbea2591766f44c9f0124f1dba..75eeb37158818991f8a5476cdd9e8896341d070a 100644 (file)
@@ -40,7 +40,7 @@ float log1pf(float x)
        k = 1;
        if (hx < 0x3ed413d0) {  /* 1+x < sqrt(2)+  */
                if (ax >= 0x3f800000) {  /* x <= -1.0 */
-                       if (x == (float)-1.0)
+                       if (x == -1.0f)
                                return -two25/zero; /* log1p(-1)=+inf */
                        return (x-x)/(x-x);         /* log1p(x<-1)=NaN */
                }
@@ -48,7 +48,7 @@ float log1pf(float x)
                        /* raise inexact */
                        if (two25 + x > zero && ax < 0x33800000)  /* |x| < 2**-24 */
                                return x;
-                       return x - x*x*(float)0.5;
+                       return x - x*x*0.5f;
                }
                if (hx > 0 || hx <= (int32_t)0xbe95f619) { /* sqrt(2)/2- <= 1+x < sqrt(2)+ */
                        k = 0;
@@ -60,11 +60,11 @@ float log1pf(float x)
                return x+x;
        if (k != 0) {
                if (hx < 0x5a000000) {
-                       STRICT_ASSIGN(float, u, (float)1.0 + x);
+                       STRICT_ASSIGN(float, u, 1.0f + x);
                        GET_FLOAT_WORD(hu, u);
                        k = (hu>>23) - 127;
                        /* correction term */
-                       c = k > 0 ? (float)1.0-(u-x) : x-(u-(float)1.0);
+                       c = k > 0 ? 1.0f-(u-x) : x-(u-1.0f);
                        c /= u;
                } else {
                        u = x;
@@ -87,9 +87,9 @@ float log1pf(float x)
                        SET_FLOAT_WORD(u, hu|0x3f000000);  /* normalize u/2 */
                        hu = (0x00800000-hu)>>2;
                }
-               f = u - (float)1.0;
+               f = u - 1.0f;
        }
-       hfsq = (float)0.5*f*f;
+       hfsq = 0.5f * f * f;
        if (hu == 0) {  /* |f| < 2**-20 */
                if (f == zero) {
                        if (k == 0)
@@ -97,12 +97,12 @@ float log1pf(float x)
                        c += k*ln2_lo;
                        return k*ln2_hi+c;
                }
-               R = hfsq*((float)1.0-(float)0.66666666666666666*f);
+               R = hfsq*(1.0f - 0.66666666666666666f * f);
                if (k == 0)
                        return f - R;
                return k*ln2_hi - ((R-(k*ln2_lo+c))-f);
        }
-       s = f/((float)2.0+f);
+       s = f/(2.0f + f);
        z = s*s;
        R = z*(Lp1+z*(Lp2+z*(Lp3+z*(Lp4+z*(Lp5+z*(Lp6+z*Lp7))))));
        if (k == 0)
index a968984d5de4e7fce396dccf09658340ef857254..c9b9282ccd2d91a83eb4ad94422eda186b7ed8dc 100644 (file)
@@ -51,8 +51,8 @@ float log2f(float x)
        SET_FLOAT_WORD(x, hx|(i^0x3f800000));  /* normalize x or x/2 */
        k += i>>23;
        y = (float)k;
-       f = x - (float)1.0;
-       hfsq = (float)0.5*f*f;
+       f = x - 1.0f;
+       hfsq = 0.5f * f * f;
        r = __log1pf(f);
 
        /*
index 285ee6151eaf9df68b961ff078a55bf63e2aad28..a4ed697b5df1037d0a736af91d7f2e56338833ac 100644 (file)
@@ -52,7 +52,7 @@ float logf(float x)
        i = (ix + (0x95f64<<3)) & 0x800000;
        SET_FLOAT_WORD(x, ix|(i^0x3f800000));  /* normalize x or x/2 */
        k += i>>23;
-       f = x - (float)1.0;
+       f = x - 1.0f;
        if ((0x007fffff & (0x8000 + ix)) < 0xc000) {  /* -2**-9 <= f < 2**-9 */
                if (f == zero) {
                        if (k == 0)
@@ -60,13 +60,13 @@ float logf(float x)
                        dk = (float)k;
                        return dk*ln2_hi + dk*ln2_lo;
                }
-               R = f*f*((float)0.5 - (float)0.33333333333333333*f);
+               R = f*f*(0.5f - 0.33333333333333333f*f);
                if (k == 0)
                        return f-R;
                dk = (float)k;
                return dk*ln2_hi - ((R-dk*ln2_lo)-f);
        }
-       s = f/((float)2.0+f);
+       s = f/(2.0f + f);
        dk = (float)k;
        z = s*s;
        i = ix-(0x6147a<<3);
@@ -77,7 +77,7 @@ float logf(float x)
        i |= j;
        R = t2 + t1;
        if (i > 0) {
-               hfsq = (float)0.5*f*f;
+               hfsq = 0.5f * f * f;
                if (k == 0)
                        return f - (hfsq-s*(hfsq+R));
                return dk*ln2_hi - ((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
index e322ff28bce1e48bff3d21f8945257c449ca86f9..c78eb12fa37a25e27f32355b2da646c704b4da7c 100644 (file)
@@ -145,7 +145,7 @@ float powf(float x, float y)
                /* now |1-x| is tiny <= 2**-20, suffice to compute
                   log(x) by x-x^2/2+x^3/3-x^4/4 */
                t = ax - 1;     /* t has 20 trailing zeros */
-               w = (t*t)*((float)0.5-t*((float)0.333333333333-t*(float)0.25));
+               w = (t*t)*(0.5f - t*(0.333333333333f - t*0.25f));
                u = ivln2_h*t;  /* ivln2_h has 16 sig. bits */
                v = t*ivln2_l - w*ivln2;
                t1 = u + v;
@@ -193,10 +193,10 @@ float powf(float x, float y)
                r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
                r += s_l*(s_h+s);
                s2 = s_h*s_h;
-               t_h = (float)3.0 + s2 + r;
+               t_h = 3.0f + s2 + r;
                GET_FLOAT_WORD(is, t_h);
                SET_FLOAT_WORD(t_h, is & 0xfffff000);
-               t_l = r - ((t_h - (float)3.0) - s2);
+               t_l = r - ((t_h - 3.0f) - s2);
                /* u+v = s*(1+...) */
                u = s_h*t_h;
                v = s_l*t_h + t_l*s;
index c17bb4f434d2f81eacc24f04838a26fc999c727d..61c3c660db78c2dc05954db9c57966c4dcae2d8c 100644 (file)
@@ -49,7 +49,7 @@ float remainderf(float x, float p)
                                x -= p;
                }
        } else {
-               p_half = (float)0.5*p;
+               p_half = 0.5f*p;
                if (x > p_half) {
                        x -= p;
                        if (x >= p_half)
index d08f2a1afe375d709eaf0aa70551671193c68d6f..94364974c7717e521a491f732410d9ae05ac18f9 100644 (file)
@@ -19,13 +19,13 @@ float scalbf(float x, float fn)
 {
        if (isnan(x) || isnan(fn)) return x*fn;
        if (!isfinite(fn)) {
-               if (fn > (float)0.0)
+               if (fn > 0.0f)
                        return x*fn;
                else
                        return x/(-fn);
        }
        if (rintf(fn) != fn) return (fn-fn)/(fn-fn);
-       if ( fn > (float)65000.0) return scalbnf(x, 65000);
-       if (-fn > (float)65000.0) return scalbnf(x,-65000);
+       if ( fn > 65000.0f) return scalbnf(x, 65000);
+       if (-fn > 65000.0f) return scalbnf(x,-65000);
        return scalbnf(x,(int)fn);
 }
index 056b5f86a1961dd92acbe2f7ec9c03f1f91c8c6b..fd11b8496767438f0b92b12fce51501025a34ef1 100644 (file)
@@ -40,7 +40,7 @@ float sinhf(float x)
                                return x;
                t = expm1f(fabsf(x));
                if (ix < 0x3f800000)
-                       return h*((float)2.0*t - t*t/(t+one));
+                       return h*(2.0f*t - t*t/(t+one));
                return h*(t + t/(t+one));
        }