diff options
-rw-r--r-- | add1sp.c | 2 | ||||
-rw-r--r-- | tests/tadd1sp.c | 23 |
2 files changed, 24 insertions, 1 deletions
@@ -319,7 +319,7 @@ mpfr_add1sp (mpfr_ptr a, mpfr_srcptr b, mpfr_srcptr c, mp_rnd_t rnd_mode) inexact = 1; set_exponent: - if (MPFR_UNLIKELY(bx >= __gmpfr_emax)) /* Check for overflow */ + if (MPFR_UNLIKELY(bx > __gmpfr_emax)) /* Check for overflow */ { DEBUG( printf("Overflow\n") ); TMP_FREE(marker); diff --git a/tests/tadd1sp.c b/tests/tadd1sp.c index 118b0e169..804e700d3 100644 --- a/tests/tadd1sp.c +++ b/tests/tadd1sp.c @@ -27,6 +27,28 @@ MA 02111-1307, USA. */ void check_special(void); void check_random(mpfr_prec_t p); +static void +check_overflow (void) +{ + mpfr_t x, y, z1, z2; + + mpfr_set_emin (-1021); + mpfr_set_emax (1024); + + mpfr_inits (x, y, z1, z2, NULL); + + mpfr_set_str1 (x, "8.00468257869324898448e+307"); + mpfr_set_str1 (y, "7.44784712422708645156e+307"); + mpfr_add1sp (z1, x, y, GMP_RNDN); + mpfr_add1 (z2, x, y, GMP_RNDN); + if (mpfr_cmp (z1, z2)) + { + printf ("Overflow bug in add1sp.\n"); + exit (1); + } + mpfr_clears (x, y, z1, z2, NULL); +} + int main(void) { mpfr_prec_t p; @@ -36,6 +58,7 @@ int main(void) check_special (); for(p = 2 ; p < 200 ; p++) check_random (p); + check_overflow (); tests_end_mpfr (); return 0; |