math: minor cleanups in ceil and floor
authornsz <nsz@port70.net>
Thu, 29 Mar 2012 12:09:57 +0000 (14:09 +0200)
committernsz <nsz@port70.net>
Thu, 29 Mar 2012 12:09:57 +0000 (14:09 +0200)
src/math/ceil.c
src/math/ceilf.c
src/math/ceill.c
src/math/floor.c
src/math/floorl.c

index c2ab4a54866f15b0d067243d23feb8c4204ce489..195551805dded45c289e6c2053eed83cd7908e76 100644 (file)
@@ -34,7 +34,6 @@ double ceil(double x)
                if (j0 < 0) {
                         /* raise inexact if x != 0 */
                        if (huge+x > 0.0) {
-                               /* return 0*sign(x) if |x|<1 */
                                if (i0 < 0) {
                                        i0 = 0x80000000;
                                        i1=0;
@@ -44,7 +43,7 @@ double ceil(double x)
                                }
                        }
                } else {
-                       i = (0x000fffff)>>j0;
+                       i = 0x000fffff>>j0;
                        if (((i0&i)|i1) == 0) /* x is integral */
                                return x;
                        /* raise inexact flag */
index d22688a7b917865dd5f9d4b443bd1f89c430f36c..fec945b6970e286d6148e040942de7dc143b45ac 100644 (file)
@@ -28,7 +28,6 @@ float ceilf(float x)
                if (j0 < 0) {
                        /* raise inexact if x != 0 */
                        if (huge+x > 0.0f) {
-                               /* return 0*sign(x) if |x|<1 */
                                if (i0 < 0)
                                        i0 = 0x80000000;
                                else if(i0 != 0)
index b938cc7f535712acf770761417e363bbfacc8fab..a3523f9d3a8258ea96ea862c38d2e91d83179383 100644 (file)
@@ -49,8 +49,7 @@ long double ceill(long double x)
 
 static const long double huge = 1.0e300;
 
-long double
-ceill(long double x)
+long double ceill(long double x)
 {
        union IEEEl2bits u = { .e = x };
        int e = u.bits.exp - LDBL_MAX_EXP + 1;
index 521a148eaff51aa156665bfd1cd13b74307aa19c..ecb9dde8b4a0749c21e24476000cfd90040483e1 100644 (file)
@@ -50,7 +50,7 @@ double floor(double x)
                                if (i0 < 0)
                                        i0 += 0x00100000>>j0;
                                i0 &= ~i;
-                               i1=0;
+                               i1 = 0;
                        }
                }
        } else if (j0 > 51) {
@@ -59,18 +59,18 @@ double floor(double x)
                else
                        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 flag */
                if (huge+x > 0.0) {
                        if (i0 < 0) {
                                if (j0 == 20)
-                                       i0+=1;
+                                       i0++;
                                else {
                                        j = i1+(1<<(52-j0));
                                        if (j < i1)
-                                               i0 += 1; /* got a carry */
+                                               i0++; /* got a carry */
                                        i1 = j;
                                }
                        }
index 08f6ba27f64f90b869388eadaf3a84990c7dbdba..3901b060b2823613a1757900683577b9810c325e 100644 (file)
@@ -97,6 +97,6 @@ long double floorl(long double x)
                if (huge + x > 0.0)
                        u.bits.manl &= ~m;
        }
-       return (u.e);
+       return u.e;
 }
 #endif