From f1278a53fcf066facd97c8c782a412b39d0f2bc4 Mon Sep 17 00:00:00 2001 From: nsz Date: Tue, 6 Mar 2012 19:34:26 +0100 Subject: [PATCH] prefer (uint)-1>>1 to ~((uint)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 diff --git a/src/math/copysign.c b/src/math/copysign.c index 04e1869..038b8b4 100644 --- a/src/math/copysign.c +++ b/src/math/copysign.c @@ -5,7 +5,7 @@ double copysign(double x, double 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; } diff --git a/src/math/copysignf.c b/src/math/copysignf.c index bf6e1c1..47ab37e 100644 --- a/src/math/copysignf.c +++ b/src/math/copysignf.c @@ -5,7 +5,7 @@ float copysignf(float x, float 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; } diff --git a/src/math/ilogbl.c b/src/math/ilogbl.c index 099c81a..3b42c4d 100644 --- a/src/math/ilogbl.c +++ b/src/math/ilogbl.c @@ -21,7 +21,7 @@ int ilogbl(long double x) } 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 diff --git a/src/math/modf.c b/src/math/modf.c index 362733e..ff85b2a 100644 --- a/src/math/modf.c +++ b/src/math/modf.c @@ -43,7 +43,7 @@ double modf(double x, double *iptr) 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; @@ -64,7 +64,7 @@ double modf(double x, double *iptr) 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; } } diff --git a/src/math/modff.c b/src/math/modff.c index 7ab10a5..d535314 100644 --- a/src/math/modff.c +++ b/src/math/modff.c @@ -37,7 +37,7 @@ float modff(float x, float *iptr) 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; diff --git a/src/math/sqrt.c b/src/math/sqrt.c index e4b166d..2ebd022 100644 --- a/src/math/sqrt.c +++ b/src/math/sqrt.c @@ -95,7 +95,7 @@ double sqrt(double x) } /* 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 */ -- 2.20.1