summaryrefslogtreecommitdiff
path: root/hypot.c
diff options
context:
space:
mode:
authorzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-01-30 12:51:58 +0000
committerzimmerma <zimmerma@280ebfd0-de03-0410-8827-d642c229c3f4>2004-01-30 12:51:58 +0000
commitd619589efd45e340bfee28fcacdab68670a1baec (patch)
treeb317b7b482bf562f937463480ecc64fddb07b6d1 /hypot.c
parent9d1f61dff6bfdd4e364adc1b173c32d7ef4c8bbb (diff)
downloadmpfr-d619589efd45e340bfee28fcacdab68670a1baec.tar.gz
added new tests for agm and hypot (+ fixed bugs)
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@2652 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'hypot.c')
-rw-r--r--hypot.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hypot.c b/hypot.c
index bd5b43704..01e02d040 100644
--- a/hypot.c
+++ b/hypot.c
@@ -85,9 +85,11 @@ mpfr_hypot (mpfr_ptr z, mpfr_srcptr x , mpfr_srcptr y , mp_rnd_t rnd_mode)
y does not overlap with the result when
x^2+y^2 < (|x| + 1/2*ulp(x,Nz))^2 = x^2 + |x|*ulp(x,Nz) + 1/4*ulp(x,Nz)^2,
i.e. a sufficient condition is y^2 < |x|*ulp(x,Nz),
- or 2^(2*Ey) <= 2^(2*Ex-1-Nz), i.e. 2*diff_exp > Nz
+ or 2^(2*Ey) <= 2^(2*Ex-1-Nz), i.e. 2*diff_exp > Nz.
+ Warning: this is true only for Nx <= Nz, otherwise the trailing bits
+ of x may be already very close to 1/2*ulp(x,Nz)!
*/
- if (diff_exp > Nz / 2) /* result is |x| or |x|+ulp(|x|,Nz) */
+ if (MPFR_PREC(x) <= Nz && diff_exp > Nz / 2) /* result is |x| or |x|+ulp(|x|,Nz) */
{
if (rnd_mode == GMP_RNDU)
{