diff options
author | nsz <nsz@port70.net> | 2012-03-29 14:09:57 +0200 |
---|---|---|
committer | nsz <nsz@port70.net> | 2012-03-29 14:09:57 +0200 |
commit | 7eabe8e69044e3683376165934a17210b6b148b9 (patch) | |
tree | 8c5c8be0860bb475a8075c54fe6cb86124b2753e | |
parent | d79ac8c38f3992b4547d155f5c8e612f51d9b32e (diff) | |
download | musl-7eabe8e69044e3683376165934a17210b6b148b9.tar.gz musl-7eabe8e69044e3683376165934a17210b6b148b9.tar.bz2 musl-7eabe8e69044e3683376165934a17210b6b148b9.tar.xz musl-7eabe8e69044e3683376165934a17210b6b148b9.zip |
math: minor cleanups in ceil and floor
-rw-r--r-- | src/math/ceil.c | 3 | ||||
-rw-r--r-- | src/math/ceilf.c | 1 | ||||
-rw-r--r-- | src/math/ceill.c | 3 | ||||
-rw-r--r-- | src/math/floor.c | 8 | ||||
-rw-r--r-- | src/math/floorl.c | 2 |
5 files changed, 7 insertions, 10 deletions
diff --git a/src/math/ceil.c b/src/math/ceil.c index c2ab4a54..19555180 100644 --- a/src/math/ceil.c +++ b/src/math/ceil.c @@ -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 */ diff --git a/src/math/ceilf.c b/src/math/ceilf.c index d22688a7..fec945b6 100644 --- a/src/math/ceilf.c +++ b/src/math/ceilf.c @@ -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) diff --git a/src/math/ceill.c b/src/math/ceill.c index b938cc7f..a3523f9d 100644 --- a/src/math/ceill.c +++ b/src/math/ceill.c @@ -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; diff --git a/src/math/floor.c b/src/math/floor.c index 521a148e..ecb9dde8 100644 --- a/src/math/floor.c +++ b/src/math/floor.c @@ -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; } } diff --git a/src/math/floorl.c b/src/math/floorl.c index 08f6ba27..3901b060 100644 --- a/src/math/floorl.c +++ b/src/math/floorl.c @@ -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 |