prefer (uint)-1>>1 to ~((uint)1<<n), remove some unnecessary ()
authornsz <nsz@port70.net>
Tue, 6 Mar 2012 18:34:26 +0000 (19:34 +0100)
committernsz <nsz@port70.net>
Tue, 6 Mar 2012 18:34:26 +0000 (19:34 +0100)
src/math/__fpclassifyl.c
src/math/copysign.c
src/math/copysignf.c
src/math/ilogbl.c
src/math/modf.c
src/math/modff.c
src/math/sqrt.c

index c886e5a..a5ad36f 100644 (file)
@@ -10,7 +10,7 @@ int __fpclassifyl(long double x)
        if (!e)
                return u.bits.m ? FP_SUBNORMAL : FP_ZERO;
        if (e == 0x7fff)
        if (!e)
                return u.bits.m ? FP_SUBNORMAL : FP_ZERO;
        if (e == 0x7fff)
-               return u.bits.m & ~((uint64_t)1<<63) ? FP_NAN : FP_INFINITE;
+               return u.bits.m & (uint64_t)-1>>1 ? FP_NAN : FP_INFINITE;
        return u.bits.m & (uint64_t)1<<63 ? FP_NORMAL : FP_NAN;
 }
 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
        return u.bits.m & (uint64_t)1<<63 ? FP_NORMAL : FP_NAN;
 }
 #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384
index 04e1869..038b8b4 100644 (file)
@@ -5,7 +5,7 @@ double copysign(double x, double y) {
 
        ux.value = x;
        uy.value = y;
 
        ux.value = x;
        uy.value = y;
-       ux.bits &= ~((uint64_t)1<<63);
+       ux.bits &= (uint64_t)-1>>1;
        ux.bits |= uy.bits & (uint64_t)1<<63;
        return ux.value;
 }
        ux.bits |= uy.bits & (uint64_t)1<<63;
        return ux.value;
 }
index bf6e1c1..47ab37e 100644 (file)
@@ -5,7 +5,7 @@ float copysignf(float x, float y) {
 
        ux.value = x;
        uy.value = y;
 
        ux.value = x;
        uy.value = y;
-       ux.bits &= ~(uint32_t)1<<31;
+       ux.bits &= (uint32_t)-1>>1;
        ux.bits |= uy.bits & (uint32_t)1<<31;
        return ux.value;
 }
        ux.bits |= uy.bits & (uint32_t)1<<31;
        return ux.value;
 }
index 099c81a..3b42c4d 100644 (file)
@@ -21,7 +21,7 @@ int ilogbl(long double x)
        }
        if (e == 0x7fff)
                /* in ld80 msb is set in inf */
        }
        if (e == 0x7fff)
                /* in ld80 msb is set in inf */
-               return m & ~((uint64_t)1<<63) ? FP_ILOGBNAN : INT_MAX;
+               return m & (uint64_t)-1>>1 ? FP_ILOGBNAN : INT_MAX;
        return e - 0x3fff;
 }
 #endif
        return e - 0x3fff;
 }
 #endif
index 362733e..ff85b2a 100644 (file)
@@ -43,7 +43,7 @@ double modf(double x, double *iptr)
                        INSERT_WORDS(x, high & 0x80000000, 0);  /* return +-0 */
                        return x;
                }
                        INSERT_WORDS(x, high & 0x80000000, 0);  /* return +-0 */
                        return x;
                }
-               INSERT_WORDS(*iptr, i0&(~i), 0);
+               INSERT_WORDS(*iptr, i0&~i, 0);
                return x - *iptr;
        } else if (j0 > 51) {  /* no fraction part */
                uint32_t high;
                return x - *iptr;
        } else if (j0 > 51) {  /* no fraction part */
                uint32_t high;
@@ -64,7 +64,7 @@ double modf(double x, double *iptr)
                        INSERT_WORDS(x, high & 0x80000000, 0);  /* return +-0 */
                        return x;
                }
                        INSERT_WORDS(x, high & 0x80000000, 0);  /* return +-0 */
                        return x;
                }
-               INSERT_WORDS(*iptr, i0, i1&(~i));
+               INSERT_WORDS(*iptr, i0, i1&~i);
                return x - *iptr;
        }
 }
                return x - *iptr;
        }
 }
index 7ab10a5..d535314 100644 (file)
@@ -37,7 +37,7 @@ float modff(float x, float *iptr)
                        SET_FLOAT_WORD(x, ix & 0x80000000);  /* return +-0 */
                        return x;
                }
                        SET_FLOAT_WORD(x, ix & 0x80000000);  /* return +-0 */
                        return x;
                }
-               SET_FLOAT_WORD(*iptr, i0&(~i));
+               SET_FLOAT_WORD(*iptr, i0&~i);
                return x - *iptr;
        } else {        /* no fraction part */
                uint32_t ix;
                return x - *iptr;
        } else {        /* no fraction part */
                uint32_t ix;
index e4b166d..2ebd022 100644 (file)
@@ -95,7 +95,7 @@ double sqrt(double x)
        }
        /* take care of zero */
        if (ix0 <= 0) {
        }
        /* take care of zero */
        if (ix0 <= 0) {
-               if (((ix0&(~sign))|ix1) == 0)
+               if (((ix0&~sign)|ix1) == 0)
                        return x;  /* sqrt(+-0) = +-0 */
                if (ix0 < 0)
                        return (x-x)/(x-x);  /* sqrt(-ve) = sNaN */
                        return x;  /* sqrt(+-0) = +-0 */
                if (ix0 < 0)
                        return (x-x)/(x-x);  /* sqrt(-ve) = sNaN */