various minor style fixes
authornsz <nsz@port70.net>
Mon, 5 Mar 2012 21:51:04 +0000 (22:51 +0100)
committernsz <nsz@port70.net>
Mon, 5 Mar 2012 21:51:04 +0000 (22:51 +0100)
12 files changed:
src/math/nextafter.c
src/math/nextafterf.c
src/math/nextafterl.c
src/math/nexttowardf.c
src/math/powl.c
src/math/remainder.c
src/math/remainderf.c
src/math/remquo.c
src/math/remquof.c
src/math/rint.c
src/math/scalbnl.c
src/math/trunc.c

index 00209d2..5e53654 100644 (file)
@@ -45,22 +45,22 @@ double nextafter(double x, double y)
        if (hx >= 0) {  /* x > 0 */
                if (hx > hy || (hx == hy && lx > ly)) {  /* x > y, x -= ulp */
                        if (lx == 0)
-                               hx -= 1;
-                       lx -= 1;
+                               hx--;
+                       lx--;
                } else {                                 /* x < y, x += ulp */
-                       lx += 1;
+                       lx++;
                        if (lx == 0)
-                               hx += 1;
+                               hx++;
                }
        } else {        /* x < 0 */
                if (hy >= 0 || hx > hy || (hx == hy && lx > ly)) { /* x < y, x -= ulp */
                        if (lx == 0)
-                               hx -= 1;
-                       lx -= 1;
+                               hx--;
+                       lx--;
                } else {                                 /* x > y, x += ulp */
-                       lx += 1;
+                       lx++;
                        if (lx == 0)
-                               hx += 1;
+                               hx++;
                }
        }
        hy = hx & 0x7ff00000;
index cba2dbe..bdc88ca 100644 (file)
@@ -40,15 +40,15 @@ float nextafterf(float x, float y)
        }
        if (hx >= 0) {         /* x > 0 */
                if (hx > hy) {             /* x > y, x -= ulp */
-                       hx -= 1;
+                       hx--;
                } else {                   /* x < y, x += ulp */
-                       hx += 1;
+                       hx++;
                }
        } else {               /* x < 0 */
                if (hy >= 0 || hx > hy) {  /* x < y, x -= ulp */
-                       hx -= 1;
+                       hx--;
                } else {                   /* x > y, x += ulp */
-                       hx += 1;
+                       hx++;
                }
        }
        hy = hx & 0x7f800000;
index 1c6d537..aec8ab4 100644 (file)
@@ -51,16 +51,16 @@ long double nextafterl(long double x, long double y)
        if(x > 0.0 ^ x < y) {  /* x -= ulp */
                if (ux.bits.manl == 0) {
                        if ((ux.bits.manh&~LDBL_NBIT) == 0)
-                               ux.bits.exp -= 1;
+                               ux.bits.exp--;
                        ux.bits.manh = (ux.bits.manh - 1) | (ux.bits.manh & LDBL_NBIT);
                }
-               ux.bits.manl -= 1;
+               ux.bits.manl--;
        } else {               /* x += ulp */
-               ux.bits.manl += 1;
+               ux.bits.manl++;
                if (ux.bits.manl == 0) {
                        ux.bits.manh = (ux.bits.manh + 1) | (ux.bits.manh & LDBL_NBIT);
                        if ((ux.bits.manh&~LDBL_NBIT)==0)
-                               ux.bits.exp += 1;
+                               ux.bits.exp++;
                }
        }
        if (ux.bits.exp == 0x7fff)  /* overflow  */
index 5e1616a..c52ef3a 100644 (file)
@@ -42,9 +42,9 @@ float nexttowardf(float x, long double y)
                return x;
        }
        if (hx >= 0 ^ x < y)  /* x -= ulp */
-               hx -= 1;
+               hx--;
        else                  /* x += ulp */
-               hx += 1;
+               hx++;
        ix = hx & 0x7f800000;
        if (ix >= 0x7f800000)  /* overflow  */
                return x+x;
index c829c18..0f0d894 100644 (file)
@@ -207,7 +207,7 @@ long double powl(long double x, long double y)
        if (y == 1.0L)
                return x;
 
-       // FIXME: this is wrong, see pow special cases in posix2008
+       // FIXME: this is wrong, see pow special cases in c99 F.9.4.4
        if (!isfinite(y) && (x == -1.0L || x == 1.0L) )
                return y - y;   /* +-1**inf is NaN */
        if (x == 1.0L)
index c9b1b2b..db176c8 100644 (file)
@@ -39,6 +39,7 @@ double remainder(double x, double p)
                return (x*p)/(x*p);
        if (hx >= 0x7ff00000 ||                              /* x not finite */
            (hp >= 0x7ff00000 && (hp-0x7ff00000 | lp) != 0)) /* p is NaN */
+               // FIXME: why long double?
                return ((long double)x*p)/((long double)x*p);
 
        if (hp <= 0x7fdfffff)
index 30875db..c17bb4f 100644 (file)
@@ -33,6 +33,7 @@ float remainderf(float x, float p)
        if (hp == 0)  /* p = 0 */
                return (x*p)/(x*p);
        if (hx >= 0x7f800000 || hp > 0x7f800000)  /* x not finite, p is NaN */
+               // FIXME: why long double?
                return ((long double)x*p)/((long double)x*p);
 
        if (hp <= 0x7effffff)
index 7ef0670..79c9a55 100644 (file)
@@ -55,9 +55,9 @@ double remquo(double x, double y, int *quo)
        /* determine ix = ilogb(x) */
        if (hx < 0x00100000) {  /* subnormal x */
                if (hx == 0) {
-                       for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;
+                       for (ix = -1043, i=lx; i>0; i<<=1) ix--;
                } else {
-                       for (ix = -1022, i=hx<<11; i>0; i<<=1) ix -=1;
+                       for (ix = -1022, i=hx<<11; i>0; i<<=1) ix--;
                }
        } else
                ix = (hx>>20) - 1023;
@@ -65,9 +65,9 @@ double remquo(double x, double y, int *quo)
        /* determine iy = ilogb(y) */
        if (hy < 0x00100000) {  /* subnormal y */
                if (hy == 0) {
-                       for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;
+                       for (iy = -1043, i=ly; i>0; i<<=1) iy--;
                } else {
-                       for (iy = -1022, i=hy<<11; i>0; i<<=1) iy -=1;
+                       for (iy = -1022, i=hy<<11; i>0; i<<=1) iy--;
                }
        } else
                iy = (hy>>20) - 1023;
@@ -134,7 +134,7 @@ double remquo(double x, double y, int *quo)
        while (hx < 0x00100000) {  /* normalize x */
                hx = hx + hx + (lx>>31);
                lx = lx + lx;
-               iy -= 1;
+               iy--;
        }
        if (iy >= -1022) {         /* normalize output */
                hx = (hx-0x00100000)|((iy+1023)<<20);
@@ -157,11 +157,11 @@ fixup:
        if (y < 0x1p-1021) {
                if (x + x > y || (x + x == y && (q & 1))) {
                        q++;
-                       x-=y;
+                       x -= y;
                }
        } else if (x > 0.5*y || (x == 0.5*y && (q & 1))) {
                q++;
-               x-=y;
+               x -= y;
        }
        GET_HIGH_WORD(hx, x);
        SET_HIGH_WORD(x, hx ^ sx);
index beff3c5..11569ce 100644 (file)
@@ -47,13 +47,13 @@ float remquof(float x, float y, int *quo)
 
        /* determine ix = ilogb(x) */
        if (hx < 0x00800000) {  /* subnormal x */
-               for (ix = -126, i=hx<<8; i>0; i<<=1) ix -=1;
+               for (ix = -126, i=hx<<8; i>0; i<<=1) ix--;
        } else
                ix = (hx>>23) - 127;
 
        /* determine iy = ilogb(y) */
        if (hy < 0x00800000) {  /* subnormal y */
-               for (iy = -126, i=hy<<8; i>0; i<<=1) iy -=1;
+               for (iy = -126, i=hy<<8; i>0; i<<=1) iy--;
        } else
                iy = (hy>>23) - 127;
 
@@ -97,7 +97,7 @@ float remquof(float x, float y, int *quo)
        }
        while (hx < 0x00800000) {  /* normalize x */
                hx <<= 1;
-               iy -= 1;
+               iy--;
        }
        if (iy >= -126) {          /* normalize output */
                hx = (hx-0x00800000)|((iy+127)<<23);
index fa6fef3..775c7b8 100644 (file)
@@ -69,7 +69,7 @@ double rint(double x)
                                else if (j0 == 18)
                                        i1 = 0x80000000;
                                else
-                                       i0 = (i0&(~i))|((0x20000)>>j0);
+                                       i0 = (i0 & ~i)|(0x20000>>j0);
                        }
                }
        } else if (j0 > 51) {
@@ -82,7 +82,7 @@ double rint(double x)
                        return x;    /* x is integral */
                i >>= 1;
                if ((i1&i) != 0)
-                       i1 = (i1&(~i))|((0x40000000)>>(j0-20));
+                       i1 = (i1 & ~i)|(0x40000000>>(j0-20));
        }
        INSERT_WORDS(x, i0, i1);
        STRICT_ASSIGN(double, w, TWO52[sx] + x);
index 5510186..0ed5b7f 100644 (file)
@@ -38,11 +38,11 @@ long double scalbnl(long double x, int n)
        if (k == 0) {                      /* 0 or subnormal x */
                if ((u.bits.manh|u.bits.manl) == 0)  /* +-0 */
                        return x;
-               u.e *= 0x1p+128;
+               u.e *= 0x1p128;
                k = u.bits.exp - 128;
                if (n < -50000)
                        return tiny*x;  /*underflow*/
-               }
+       }
        if (k == 0x7fff)                   /* NaN or Inf */
                return x + x;
        k = k + n;
index b0b80d1..44b04ec 100644 (file)
@@ -37,7 +37,7 @@ double trunc(double x)
                                i1 = 0;
                        }
                } else {
-                       i = (0x000fffff)>>j0;
+                       i = 0x000fffff>>j0;
                        if (((i0&i)|i1) == 0)
                                return x; /* x is integral */
                        /* raise inexact */
@@ -51,7 +51,7 @@ double trunc(double x)
                        return x + x;  /* inf or NaN */
                return x;              /* x is integral */
        } else {
-               i = ((uint32_t)(0xffffffff))>>(j0-20);
+               i = (uint32_t)0xffffffff>>(j0-20);
                if ((i1&i) == 0)
                        return x;      /* x is integral */
                /* raise inexact */