summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaney <daney@280ebfd0-de03-0410-8827-d642c229c3f4>2001-10-26 13:05:58 +0000
committerdaney <daney@280ebfd0-de03-0410-8827-d642c229c3f4>2001-10-26 13:05:58 +0000
commit064da86713fe08329742fbc8c70b310f9897c0e5 (patch)
treed2b3d58f6732bb9fc4f79154e931bcf62cd99851
parent394a26ccfa8db41b3ef2ec8e21a419c11b8f7e2f (diff)
downloadmpfr-064da86713fe08329742fbc8c70b310f9897c0e5.tar.gz
err <0 => is now tester
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@1423 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--hypot.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/hypot.c b/hypot.c
index 686be47fb..4e9072d6a 100644
--- a/hypot.c
+++ b/hypot.c
@@ -85,7 +85,7 @@ mpfr_hypot (z, x,y, rnd_mode)
mp_prec_t Nz = MPFR_PREC(z); /* Precision of input variable */
mp_prec_t Nt; /* Precision of the intermediary variable */
- mp_prec_t err; /* Precision of error */
+ long int err; /* Precision of error */
/* compute the precision of intermediary variable */
Nt=MAX(MAX(Nx,Ny),Nz);
@@ -100,6 +100,7 @@ mpfr_hypot (z, x,y, rnd_mode)
/* Hypot */
do {
+ not_exact=0;
/* reactualisation of the precision */
mpfr_set_prec(t,Nt);
mpfr_set_prec(te,Nt);
@@ -108,10 +109,13 @@ mpfr_hypot (z, x,y, rnd_mode)
/* computations of hypot */
if(mpfr_mul(te,x,x,GMP_RNDN)) /* x^2 */
not_exact=1;
+
if(mpfr_mul(ti,y,y,GMP_RNDN)) /* y^2 */
+ not_exact=1;
+
+ if(mpfr_add(t,te,ti,GMP_RNDD)) /*x^2+y^2*/
not_exact=1;
- if(mpfr_add(t,te,ti,GMP_RNDD)) /* x^2+y^2*/
- not_exact=1;
+
if(mpfr_sqrt(t,t,GMP_RNDN)) /* sqrt(x^2+y^2)*/
not_exact=1;
@@ -120,7 +124,7 @@ mpfr_hypot (z, x,y, rnd_mode)
Nt += 10;
- } while ((!mpfr_can_round(t,err,GMP_RNDN,rnd_mode,Nz)) && not_exact);
+ } while ((err <0) || ((!mpfr_can_round(t,err,GMP_RNDN,rnd_mode,Nz)) && not_exact));
inexact = mpfr_set (z, t, rnd_mode);
mpfr_clear(t);