summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mpfr.h2
-rw-r--r--tests/tadd1sp.c2
-rw-r--r--tests/tfactorial.c2
-rw-r--r--tests/tget_f.c2
-rw-r--r--tests/tmul.c5
-rw-r--r--tests/tmul_ui.c2
-rw-r--r--tests/tpow.c4
-rw-r--r--tests/trint.c24
-rw-r--r--tests/troot.c2
-rw-r--r--tests/tsqr.c2
-rw-r--r--tests/tsqrt.c2
-rw-r--r--tests/tsub1sp.c2
-rw-r--r--tests/tui_div.c4
13 files changed, 30 insertions, 25 deletions
diff --git a/src/mpfr.h b/src/mpfr.h
index a035a3582..710347301 100644
--- a/src/mpfr.h
+++ b/src/mpfr.h
@@ -159,7 +159,7 @@ typedef unsigned long mpfr_uprec_t;
also make sure that MPFR_PREC_MIN and MPFR_PREC_MAX have a signed
integer type. The "- 256" allows more security, avoiding some
integer overflows in extreme cases; ideally it should be useless. */
-#define MPFR_PREC_MIN 2
+#define MPFR_PREC_MIN 1
#define MPFR_PREC_MAX ((mpfr_prec_t) ((((mpfr_uprec_t) -1) >> 1) - 256))
/* Definition of sign */
diff --git a/tests/tadd1sp.c b/tests/tadd1sp.c
index a7c63cbb7..93e8a7664 100644
--- a/tests/tadd1sp.c
+++ b/tests/tadd1sp.c
@@ -62,7 +62,7 @@ main (void)
tests_start_mpfr ();
check_special ();
- for(p = 2 ; p < 200 ; p++)
+ for(p = MPFR_PREC_MIN; p < 200 ; p++)
check_random (p);
check_overflow ();
diff --git a/tests/tfactorial.c b/tests/tfactorial.c
index 4e5b3d679..4886fa71f 100644
--- a/tests/tfactorial.c
+++ b/tests/tfactorial.c
@@ -212,7 +212,7 @@ main (int argc, char *argv[])
exit (1);
}
- for (prec = 2; prec <= 100; prec++)
+ for (prec = MPFR_PREC_MIN; prec <= 100; prec++)
{
mpfr_set_prec (x, prec);
mpfr_set_prec (z, prec);
diff --git a/tests/tget_f.c b/tests/tget_f.c
index bfae85afc..a1eef4443 100644
--- a/tests/tget_f.c
+++ b/tests/tget_f.c
@@ -176,7 +176,7 @@ ternary_test (void)
mpf_init2 (x, 256);
mpfr_init2 (y, 256);
- for (prec = 2; prec <= 256; prec++)
+ for (prec = MPFR_PREC_MIN; prec <= 256; prec++)
{
mpf_set_prec (x, prec);
diff --git a/tests/tmul.c b/tests/tmul.c
index 4300de6d4..0422bcb01 100644
--- a/tests/tmul.c
+++ b/tests/tmul.c
@@ -209,11 +209,12 @@ check_exact (void)
exit (1);
}
- for (prec = 2; prec < 100; prec++)
+ for (prec = MPFR_PREC_MIN; prec < 100; prec++)
{
mpfr_set_prec (a, prec);
mpfr_set_prec (b, prec);
- mpfr_set_prec (c, 2 * prec - 2);
+ /* for prec=1, ensure PREC(c) >= 1 */
+ mpfr_set_prec (c, 2 * prec - 2 + (prec == 1));
mpfr_set_prec (d, 2 * prec);
for (i = 0; i < 1000; i++)
{
diff --git a/tests/tmul_ui.c b/tests/tmul_ui.c
index 63f38e95c..84a012d2c 100644
--- a/tests/tmul_ui.c
+++ b/tests/tmul_ui.c
@@ -42,7 +42,7 @@ check_inexact (mpfr_prec_t p)
exit (1);
}
- for (q = 2; q <= p; q++)
+ for (q = MPFR_PREC_MIN; q <= p; q++)
for (rnd = 0; rnd < MPFR_RND_MAX; rnd++)
{
mpfr_set_prec (y, q);
diff --git a/tests/tpow.c b/tests/tpow.c
index 7ff08a9ee..03ee9aba0 100644
--- a/tests/tpow.c
+++ b/tests/tpow.c
@@ -422,7 +422,7 @@ check_inexact (mpfr_prec_t p)
mpfr_init (t);
mpfr_urandomb (x, RANDS);
u = randlimb () % 2;
- for (q = 2; q <= p; q++)
+ for (q = MPFR_PREC_MIN; q <= p; q++)
for (rnd = 0; rnd < MPFR_RND_MAX; rnd++)
{
mpfr_set_prec (y, q);
@@ -1595,7 +1595,7 @@ main (int argc, char **argv)
check_pow_si ();
check_special_pow_si ();
pow_si_long_min ();
- for (p = 2; p < 100; p++)
+ for (p = MPFR_PREC_MIN; p < 100; p++)
check_inexact (p);
underflows ();
overflows ();
diff --git a/tests/trint.c b/tests/trint.c
index 3c8f33a06..9a21db87c 100644
--- a/tests/trint.c
+++ b/tests/trint.c
@@ -263,7 +263,7 @@ basic_tests (void)
emax = mpfr_get_emax ();
mpfr_init2 (x, 16);
- for (prec = 2; prec <= 7; prec++)
+ for (prec = MPFR_PREC_MIN; prec <= 7; prec++)
{
mpfr_inits2 (prec, y, z, (mpfr_ptr) 0);
for (s = 1; s >= -1; s -= 2)
@@ -494,27 +494,31 @@ main (int argc, char *argv[])
mpfr_init (u);
mpfr_init (v);
mpz_set_ui (z, 1);
- for (s = 2; s < 100; s++)
+ /* the code below works for 1 <= MPFR_PREC_MIN <= 2 */
+ MPFR_ASSERTN(1 <= MPFR_PREC_MIN && MPFR_PREC_MIN <= 2);
+ for (s = MPFR_PREC_MIN; s < 100; s++)
{
- /* z has exactly s bits */
-
- mpz_mul_2exp (z, z, 1);
- if (randlimb () % 2)
- mpz_add_ui (z, z, 1);
+ if (s > 1)
+ {
+ mpz_mul_2exp (z, z, 1);
+ if (randlimb () % 2)
+ mpz_add_ui (z, z, 1);
+ }
+ /* now 2^(s-1) <= z < 2^s */
mpfr_set_prec (x, s);
mpfr_set_prec (t, s);
mpfr_set_prec (u, s);
if (mpfr_set_z (x, z, MPFR_RNDN))
{
- printf ("Error: mpfr_set_z should be exact (s = %u)\n",
- (unsigned int) s);
+ gmp_printf ("Error: mpfr_set_z should be exact (z = %Zd, s = %u)\n",
+ z, (unsigned int) s);
exit (1);
}
if (randlimb () % 2)
mpfr_neg (x, x, MPFR_RNDN);
if (randlimb () % 2)
mpfr_div_2ui (x, x, randlimb () % s, MPFR_RNDN);
- for (p = 2; p < 100; p++)
+ for (p = MPFR_PREC_MIN; p < 100; p++)
{
int trint;
mpfr_set_prec (y, p);
diff --git a/tests/troot.c b/tests/troot.c
index 896a17783..c89edcb48 100644
--- a/tests/troot.c
+++ b/tests/troot.c
@@ -295,7 +295,7 @@ main (void)
mpfr_init (x);
- for (p = 2; p < 100; p++)
+ for (p = MPFR_PREC_MIN; p < 100; p++)
{
mpfr_set_prec (x, p);
for (r = 0; r < MPFR_RND_MAX; r++)
diff --git a/tests/tsqr.c b/tests/tsqr.c
index 037cdb164..45444b54e 100644
--- a/tests/tsqr.c
+++ b/tests/tsqr.c
@@ -163,7 +163,7 @@ main (void)
check_mpn_sqr ();
check_special ();
- for (p = 2; p < 200; p++)
+ for (p = MPFR_PREC_MIN; p < 200; p++)
check_random (p);
test_generic (2, 200, 15);
diff --git a/tests/tsqrt.c b/tests/tsqrt.c
index d007bb9f7..34551cadb 100644
--- a/tests/tsqrt.c
+++ b/tests/tsqrt.c
@@ -320,7 +320,7 @@ special (void)
/* case prec(result) << prec(input) */
mpfr_set_prec (z, 2);
- for (p = 2; p < 1000; p++)
+ for (p = mpfr_get_prec (z); p < 1000; p++)
{
mpfr_set_prec (x, p);
mpfr_set_ui (x, 1, MPFR_RNDN);
diff --git a/tests/tsub1sp.c b/tests/tsub1sp.c
index 90ba04a91..91d66d17c 100644
--- a/tests/tsub1sp.c
+++ b/tests/tsub1sp.c
@@ -33,7 +33,7 @@ main (void)
tests_start_mpfr ();
check_special ();
- for (p = 2 ; p < 200 ; p++)
+ for (p = MPFR_PREC_MIN ; p < 200 ; p++)
check_random (p);
tests_end_mpfr ();
diff --git a/tests/tui_div.c b/tests/tui_div.c
index b7a55cdd8..d444237ff 100644
--- a/tests/tui_div.c
+++ b/tests/tui_div.c
@@ -55,7 +55,7 @@ check_inexact (void)
mpfr_init (y);
mpfr_init (z);
- for (px = 2; px < 300; px++)
+ for (px = MPFR_PREC_MIN; px < 300; px++)
{
mpfr_set_prec (x, px);
do
@@ -64,7 +64,7 @@ check_inexact (void)
}
while (mpfr_cmp_ui (x, 0) == 0);
u = randlimb ();
- for (py = 2; py < 300; py++)
+ for (py = MPFR_PREC_MIN; py < 300; py++)
{
mpfr_set_prec (y, py);
mpfr_set_prec (z, py + px);