diff options
author | daney <daney@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-10-26 13:05:58 +0000 |
---|---|---|
committer | daney <daney@280ebfd0-de03-0410-8827-d642c229c3f4> | 2001-10-26 13:05:58 +0000 |
commit | 064da86713fe08329742fbc8c70b310f9897c0e5 (patch) | |
tree | d2b3d58f6732bb9fc4f79154e931bcf62cd99851 | |
parent | 394a26ccfa8db41b3ef2ec8e21a419c11b8f7e2f (diff) | |
download | mpfr-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.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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); |