diff options
author | Szabolcs Nagy <nsz@port70.net> | 2013-09-04 17:36:00 +0000 |
---|---|---|
committer | Szabolcs Nagy <nsz@port70.net> | 2013-09-05 11:30:09 +0000 |
commit | 8dba5486288e719ed290cccefcd932ed32756d7c (patch) | |
tree | 7e9cac9140e4c2c54e31cd817e95e135833a0deb /src/math/nexttowardf.c | |
parent | 63b9cc777323488da3474e8bc53e0ac4d3521382 (diff) | |
download | musl-8dba5486288e719ed290cccefcd932ed32756d7c.tar.gz |
math: cosmetic cleanup (use explicit union instead of fshape and dshape)
Diffstat (limited to 'src/math/nexttowardf.c')
-rw-r--r-- | src/math/nexttowardf.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/math/nexttowardf.c b/src/math/nexttowardf.c index 9a693b1a..bbf172f9 100644 --- a/src/math/nexttowardf.c +++ b/src/math/nexttowardf.c @@ -2,35 +2,34 @@ float nexttowardf(float x, long double y) { - union fshape ux; + union {float f; uint32_t i;} ux = {x}; uint32_t e; if (isnan(x) || isnan(y)) return x + y; if (x == y) return y; - ux.value = x; if (x == 0) { - ux.bits = 1; + ux.i = 1; if (signbit(y)) - ux.bits |= 0x80000000; + ux.i |= 0x80000000; } else if (x < y) { if (signbit(x)) - ux.bits--; + ux.i--; else - ux.bits++; + ux.i++; } else { if (signbit(x)) - ux.bits++; + ux.i++; else - ux.bits--; + ux.i--; } - e = ux.bits & 0x7f800000; - /* raise overflow if ux.value is infinite and x is finite */ + e = ux.i & 0x7f800000; + /* raise overflow if ux.f is infinite and x is finite */ if (e == 0x7f800000) FORCE_EVAL(x+x); - /* raise underflow if ux.value is subnormal or zero */ + /* raise underflow if ux.f is subnormal or zero */ if (e == 0) - FORCE_EVAL(x*x + ux.value*ux.value); - return ux.value; + FORCE_EVAL(x*x + ux.f*ux.f); + return ux.f; } |