X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmath%2Fnextafterl.c;h=37e858fb4982a775cc4099738c539c8bd2f25d76;hb=7be59733d71ada3a32a98622507399253f1d5e48;hp=611ea53dbcef4b615cc21c0d85d8110a205c4c4d;hpb=a45de0cb94b58f1b5ea4af1ca3531c56dc02c0a2;p=musl diff --git a/src/math/nextafterl.c b/src/math/nextafterl.c index 611ea53d..37e858fb 100644 --- a/src/math/nextafterl.c +++ b/src/math/nextafterl.c @@ -6,7 +6,6 @@ long double nextafterl(long double x, long double y) return nextafter(x, y); } #elif LDBL_MANT_DIG == 64 && LDBL_MAX_EXP == 16384 -#define MSB ((uint64_t)1<<63) long double nextafterl(long double x, long double y) { union ldshape ux, uy; @@ -15,33 +14,32 @@ long double nextafterl(long double x, long double y) return x + y; if (x == y) return y; - ux.value = x; + ux.f = x; if (x == 0) { - uy.value = y; - ux.bits.m = 1; - ux.bits.sign = uy.bits.sign; - } else if (x < y ^ ux.bits.sign) { - ux.bits.m++; - if ((ux.bits.m & ~MSB) == 0) { - ux.bits.m = MSB; - ux.bits.exp++; + uy.f = y; + ux.i.m = 1; + ux.i.se = uy.i.se & 0x8000; + } else if ((x < y) == !(ux.i.se & 0x8000)) { + ux.i.m++; + if (ux.i.m << 1 == 0) { + ux.i.m = 1ULL << 63; + ux.i.se++; } } else { - if ((ux.bits.m & ~MSB) == 0) { - ux.bits.exp--; - if (ux.bits.exp) - ux.bits.m = 0; + if (ux.i.m << 1 == 0) { + ux.i.se--; + if (ux.i.se) + ux.i.m = 0; } - ux.bits.m--; + ux.i.m--; } - /* raise overflow if ux.value is infinite and x is finite */ - if (ux.bits.exp == 0x7fff) + /* raise overflow if ux is infinite and x is finite */ + if ((ux.i.se & 0x7fff) == 0x7fff) return x + x; - /* raise underflow if ux.value is subnormal or zero */ - if (ux.bits.exp == 0) { - volatile float z = x*x + ux.value*ux.value; - } - return ux.value; + /* raise underflow if ux is subnormal or zero */ + if ((ux.i.se & 0x7fff) == 0) + FORCE_EVAL(x*x + ux.f*ux.f); + return ux.f; } #elif LDBL_MANT_DIG == 113 && LDBL_MAX_EXP == 16384 long double nextafterl(long double x, long double y) @@ -52,33 +50,26 @@ long double nextafterl(long double x, long double y) return x + y; if (x == y) return y; - ux.value = x; + ux.f = x; if (x == 0) { - uy.value = y; - ux.bits.mlo = 1; - ux.bits.sign = uy.bits.sign; - } else if (x < y ^ ux.bits.sign) { - ux.bits.mlo++; - if (ux.bits.mlo == 0) { - ux.bits.mhi++; - if (ux.bits.mhi == 0) - ux.bits.exp++; - } + uy.f = y; + ux.i.lo = 1; + ux.i.se = uy.i.se & 0x8000; + } else if ((x < y) == !(ux.i.se & 0x8000)) { + ux.i2.lo++; + if (ux.i2.lo == 0) + ux.i2.hi++; } else { - if (ux.bits.mlo == 0) { - if (ux.bits.mhi == 0) - ux.bits.exp--; - ux.bits.mhi--; - } - ux.bits.mlo--; + if (ux.i2.lo == 0) + ux.i2.hi--; + ux.i2.lo--; } - /* raise overflow if ux.value is infinite and x is finite */ - if (ux.bits.exp == 0x7fff) + /* raise overflow if ux is infinite and x is finite */ + if ((ux.i.se & 0x7fff) == 0x7fff) return x + x; - /* raise underflow if ux.value is subnormal or zero */ - if (ux.bits.exp == 0) { - volatile float z = x*x + ux.value*ux.value; - } - return ux.value; + /* raise underflow if ux is subnormal or zero */ + if ((ux.i.se & 0x7fff) == 0) + FORCE_EVAL(x*x + ux.f*ux.f); + return ux.f; } #endif