summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-30 12:10:21 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2004-04-30 12:10:21 +0000
commitf64fe45deeb54d06f4fd3aaf48faf59bac81f027 (patch)
tree92f71ab9c94911b79e3305eb2e488a6aaf396b1a
parentf99c922219aac5f11e2ca25fceb13f8f1f1bd820 (diff)
downloadmpfr-2-0-2-branch.tar.gz
Ported bug fix / test in case a mpz_t == 0 (mpz_sizeinbase(0Z,2)==0mpfr-2-0-2-branch
and MPFR_PREC_MIN=2) to the 2.0 branch (fixed on 2004-04-07 in the trunk). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/branches/mpfr-2-0-2-branch@2886 280ebfd0-de03-0410-8827-d642c229c3f4
-rw-r--r--gmp_op.c8
-rw-r--r--tests/tgmpop.c18
2 files changed, 21 insertions, 5 deletions
diff --git a/gmp_op.c b/gmp_op.c
index a911e3b35..8b2040bba 100644
--- a/gmp_op.c
+++ b/gmp_op.c
@@ -30,7 +30,7 @@ mpfr_mul_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z,mp_rnd_t rnd_mode)
{
mpfr_t t;
int res;
- mpfr_init2(t, mpz_sizeinbase(z, 2) );
+ mpfr_init2(t, mpz_sizeinbase(z, 2) + MPFR_PREC_MIN);
res = mpfr_set_z(t, z, rnd_mode);
MPFR_ASSERTD(res == 0);
res = mpfr_mul(y, x, t, rnd_mode);
@@ -43,7 +43,7 @@ mpfr_div_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z, mp_rnd_t rnd_mode)
{
mpfr_t t;
int res;
- mpfr_init2(t, mpz_sizeinbase(z, 2) );
+ mpfr_init2(t, mpz_sizeinbase(z, 2) + MPFR_PREC_MIN);
res = mpfr_set_z(t, z, rnd_mode);
MPFR_ASSERTD(res == 0);
res = mpfr_div(y, x, t, rnd_mode);
@@ -56,7 +56,7 @@ mpfr_add_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z, mp_rnd_t rnd_mode)
{
mpfr_t t;
int res;
- mpfr_init2(t, mpz_sizeinbase(z, 2) );
+ mpfr_init2(t, mpz_sizeinbase(z, 2) + MPFR_PREC_MIN);
res = mpfr_set_z(t, z, rnd_mode);
MPFR_ASSERTD(res == 0);
res = mpfr_add(y, x, t, rnd_mode);
@@ -69,7 +69,7 @@ mpfr_sub_z (mpfr_ptr y, mpfr_srcptr x, mpz_srcptr z,mp_rnd_t rnd_mode)
{
mpfr_t t;
int res;
- mpfr_init2(t, mpz_sizeinbase(z, 2) );
+ mpfr_init2(t, mpz_sizeinbase(z, 2) + MPFR_PREC_MIN);
res = mpfr_set_z(t, z, rnd_mode);
MPFR_ASSERTD(res == 0);
res=mpfr_sub(y, x, t, rnd_mode);
diff --git a/tests/tgmpop.c b/tests/tgmpop.c
index efcd95611..edf8b8c84 100644
--- a/tests/tgmpop.c
+++ b/tests/tgmpop.c
@@ -125,7 +125,23 @@ test_specialz (int (*mpfr_func)(mpfr_ptr, mpfr_srcptr, mpz_srcptr, mp_rnd_t),
putchar('\n');
abort();
}
-
+
+ mpz_set_ui (z1, 1);
+ mpz_set_ui (z2, 0);
+ mpfr_set_ui (x1, 1, GMP_RNDN);
+ mpz_func (z1, z1, z2);
+ res = mpfr_func(x1, x1, z2, GMP_RNDN);
+ mpfr_set_z (x2, z1, GMP_RNDN);
+ if (mpfr_cmp(x1, x2))
+ {
+ printf("Specialz %s: results differ(2).\nx1=", op);
+ mpfr_print_binary(x1);
+ printf("\nx2=");
+ mpfr_print_binary(x2);
+ putchar('\n');
+ exit(1);
+ }
+
mpz_clear (z1); mpz_clear(z2);
mpfr_clears(x1, x2, NULL);
}