* lib/ldexp.c (FUNC): Don’t assume two’s-complement.
+2023-08-20 Paul Eggert <eggert@cs.ucla.edu>
+
+ ldexp: port to non-two’s complement
+ * lib/ldexp.c (FUNC): Don’t assume two’s-complement.
+
2023-08-20 Bruno Haible <bruno@clisp.org>
readutmp, boot-time: Fix the result on runit and s6 init systems.
BEGIN_ROUNDING ();
/* Check for zero, nan and infinity. */
- if (!(ISNAN (x) || x + x == x || exp == 0))
+ if (!(ISNAN (x) || x + x == x))
{
- bool negexp = exp < 0;
- DOUBLE factor = negexp ? L_(0.5) : L_(2.0);
+ DOUBLE factor = exp < 0 ? L_(0.5) : L_(2.0);
while (true)
{
- if (exp & 1)
+ if (exp % 2 != 0)
x *= factor;
- exp = (exp + negexp) >> 1;
+ exp /= 2;
if (exp == 0)
break;
factor = factor * factor;