diff options
author | enge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2009-06-05 08:36:03 +0000 |
---|---|---|
committer | enge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2009-06-05 08:36:03 +0000 |
commit | 3a7719ad3b60c06de3bd9d84741aaa14556e9728 (patch) | |
tree | edbcb54da6035c84aed3790e56f2380a9505e1d4 | |
parent | 594864a3280b2f261ac79a6e27932234c5072d2c (diff) | |
download | mpc-3a7719ad3b60c06de3bd9d84741aaa14556e9728.tar.gz |
norm: corrected return value to + in case of overflow
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@562 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r-- | src/norm.c | 7 | ||||
-rw-r--r-- | tests/norm.dat | 2 |
2 files changed, 4 insertions, 5 deletions
@@ -26,7 +26,7 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mp_rnd_t rnd) { mpfr_t u, v; mp_prec_t prec; - int inexact; + int inexact, overflow; prec = MPFR_PREC(a); @@ -65,10 +65,9 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mp_rnd_t rnd) inexact |= mpfr_sqr (v, MPC_IM(b), GMP_RNDN); /* err<=1/2ulp*/ inexact |= mpfr_add (u, u, v, GMP_RNDN); /* err <= 3/2 ulps */ - if (mpfr_inf_p (u)) - inexact = 0; + overflow = mpfr_inf_p (u); } - while (inexact != 0 && + while (!overflow && inexact && mpfr_can_round (u, prec - 2, GMP_RNDN, rnd, MPFR_PREC(a)) == 0); inexact |= mpfr_set (a, u, rnd); diff --git a/tests/norm.dat b/tests/norm.dat index 473550e..19322c6 100644 --- a/tests/norm.dat +++ b/tests/norm.dat @@ -75,4 +75,4 @@ 0 7 2 7 1 7 1 N # overflow -0 53 +inf 2 0x1p536870912 2 0x1p536870912 U ++ 53 +inf 2 0x1p536870912 2 0x1p536870912 U |