[Gmp-commit] /var/hg/gmp: Use a wider range of bases.

mercurial at gmplib.org mercurial at gmplib.org
Fri Jun 1 12:36:54 CEST 2012


details:   /var/hg/gmp/rev/5be212beb8e9
changeset: 15035:5be212beb8e9
user:      Torbjorn Granlund <tege at gmplib.org>
date:      Fri Jun 01 12:36:50 2012 +0200
description:
Use a wider range of bases.

diffstat:

 ChangeLog      |   2 ++
 tests/mpz/io.c |  13 +++++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diffs (51 lines):

diff -r 0c9d2b9c1fd9 -r 5be212beb8e9 ChangeLog
--- a/ChangeLog	Fri Jun 01 12:11:12 2012 +0200
+++ b/ChangeLog	Fri Jun 01 12:36:50 2012 +0200
@@ -1,5 +1,7 @@
 2012-06-01  Torbjorn Granlund  <tege at gmplib.org>
 
+	* tests/mpz/io.c: Use a wider range of bases.
+
 	* tests/mpz/t-cong.c (check_random): Rewrite random generation for
 	exponentially distributed operand sizes.
 
diff -r 0c9d2b9c1fd9 -r 5be212beb8e9 tests/mpz/io.c
--- a/tests/mpz/io.c	Fri Jun 01 12:11:12 2012 +0200
+++ b/tests/mpz/io.c	Fri Jun 01 12:36:50 2012 +0200
@@ -1,6 +1,6 @@
 /* Test conversion and I/O using mpz_out_str and mpz_inp_str.
 
-Copyright 1993, 1994, 1996, 2000, 2001 Free Software Foundation, Inc.
+Copyright 1993, 1994, 1996, 2000, 2001, 2012 Free Software Foundation, Inc.
 
 This file is part of the GNU MP Library.
 
@@ -45,7 +45,7 @@
   int i;
   int reps = 10000;
   FILE *fp;
-  int base;
+  int base, base_out;
   gmp_randstate_ptr rands;
   mpz_t bs;
   unsigned long bsi, size_range;
@@ -79,12 +79,17 @@
 
       mpz_urandomb (bs, rands, 16);
       bsi = mpz_get_ui (bs);
-      base = bsi % 36 + 1;
+      base = bsi % 62 + 1;
       if (base == 1)
 	base = 0;
 
+      if (i % 2 == 0 && base <= 36)
+	base_out = -base;
+      else
+	base_out = base;
+
       rewind (fp);
-      if (mpz_out_str (fp, base, op1) == 0
+      if (mpz_out_str (fp, base_out, op1) == 0
 	  || putc (' ', fp) == EOF
 	  || fflush (fp) != 0)
 	{


More information about the gmp-commit mailing list