diff options
author | enge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2009-06-04 16:35:44 +0000 |
---|---|---|
committer | enge <enge@211d60ee-9f03-0410-a15a-8952a2c7a4e4> | 2009-06-04 16:35:44 +0000 |
commit | 5e0c14ae8c276b91ff571003c3fd448beeb2fa3e (patch) | |
tree | d417524c632b4c75dfcab617f45c88d44226ddfa | |
parent | b4e2005a89669ca9ffadfa7191ae7adcefe19824 (diff) | |
download | mpc-5e0c14ae8c276b91ff571003c3fd448beeb2fa3e.tar.gz |
fixed norm computation: returns inf in case of overflow
git-svn-id: svn://scm.gforge.inria.fr/svn/mpc/trunk@557 211d60ee-9f03-0410-a15a-8952a2c7a4e4
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | src/norm.c | 7 | ||||
-rw-r--r-- | tests/norm.dat | 2 |
3 files changed, 8 insertions, 4 deletions
@@ -1,7 +1,8 @@ Recent Changes: - New functions: mpc_pow - Bug fixes: - - log (along branch cut) + - log: along branch cut + - norm: infinite loop in case of overflow - Makefile.vc updated (thanks to Mickael Gastineau) - Minimal gmp version is 4.2 - Changed MPC_SET_X_Y macro @@ -61,11 +61,12 @@ mpc_norm (mpfr_ptr a, mpc_srcptr b, mp_rnd_t rnd) mpfr_set_prec (u, prec); mpfr_set_prec (v, prec); - /* first compute norm(b)^2 */ - inexact = mpfr_sqr (u, MPC_RE(b), GMP_RNDN); /* err<=1/2ulp */ + inexact = mpfr_sqr (u, MPC_RE(b), GMP_RNDN); /* err<=1/2ulp */ inexact |= mpfr_sqr (v, MPC_IM(b), GMP_RNDN); /* err<=1/2ulp*/ + inexact |= mpfr_add (u, u, v, GMP_RNDN); /* err <= 3/2 ulps */ - inexact |= mpfr_add (u, u, v, GMP_RNDN); /* err <= 3/2 ulps */ + if (mpfr_inf_p (u)) + inexact = 0; } while (inexact != 0 && mpfr_can_round (u, prec - 2, GMP_RNDN, rnd, MPFR_PREC(a)) == 0); diff --git a/tests/norm.dat b/tests/norm.dat index 47d7209..473550e 100644 --- a/tests/norm.dat +++ b/tests/norm.dat @@ -74,3 +74,5 @@ 0 7 1 7 1 7 +0 N 0 7 2 7 1 7 1 N +# overflow +0 53 +inf 2 0x1p536870912 2 0x1p536870912 U |