about summary refs log tree commit diff
path: root/math/gen-auto-libm-tests.c
diff options
context:
space:
mode:
Diffstat (limited to 'math/gen-auto-libm-tests.c')
-rw-r--r--math/gen-auto-libm-tests.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c
index 2f521d5c83..198d001519 100644
--- a/math/gen-auto-libm-tests.c
+++ b/math/gen-auto-libm-tests.c
@@ -987,7 +987,14 @@ adjust_real (mpfr_t r, bool inexact)
       mpz_t tmp;
       mpz_init (tmp);
       mpfr_exp_t e = mpfr_get_z_2exp (tmp, r);
-      mpz_setbit (tmp, 0);
+      if (mpz_sgn (tmp) < 0)
+	{
+	  mpz_neg (tmp, tmp);
+	  mpz_setbit (tmp, 0);
+	  mpz_neg (tmp, tmp);
+	}
+      else
+	mpz_setbit (tmp, 0);
       assert_exact (mpfr_set_z_2exp (r, tmp, e, MPFR_RNDN));
       mpz_clear (tmp);
     }