[Gmp-commit] /var/hg/gmp: 2 new changesets

mercurial at gmplib.org mercurial at gmplib.org
Sat Dec 15 07:07:45 UTC 2018


details:   /var/hg/gmp/rev/49f58e3c3017
changeset: 17733:49f58e3c3017
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sat Dec 15 08:03:57 2018 +0100
description:
mini-gmp/tests/t-bitops.c: Somehow test also mpz_com.

details:   /var/hg/gmp/rev/0b950ea75d42
changeset: 17734:0b950ea75d42
user:      Marco Bodrato <bodrato at mail.dm.unipi.it>
date:      Sat Dec 15 08:07:13 2018 +0100
description:
mini-gmp/mini-gmp.c (gmp_stronglucas): add a cast.
(mpz_com): invert order of operations.

diffstat:

 mini-gmp/mini-gmp.c       |  6 +++---
 mini-gmp/tests/t-bitops.c |  3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)

diffs (43 lines):

diff -r afae8fd2739d -r 0b950ea75d42 mini-gmp/mini-gmp.c
--- a/mini-gmp/mini-gmp.c	Wed Dec 12 04:02:51 2018 +0100
+++ b/mini-gmp/mini-gmp.c	Sat Dec 15 08:07:13 2018 +0100
@@ -3581,7 +3581,7 @@
   b0 = mpz_scan0 (n, 0);
 
   /* D= P^2 - 4Q; P = 1; Q = (1-D)/4 */
-  Q = (D & 2) ? (D >> 2) + 1 : -(D >> 2);
+  Q = (D & 2) ? (D >> 2) + 1 : -(long) (D >> 2);
 
   if (! mpz_lucas_mod (V, Qk, Q, b0, n))	/* If Ud != 0 */
     while (V->_mp_size != 0 && --b0 != 0)	/* while Vk != 0 */
@@ -3848,8 +3848,8 @@
 void
 mpz_com (mpz_t r, const mpz_t u)
 {
-  mpz_neg (r, u);
-  mpz_sub_ui (r, r, 1);
+  mpz_add_ui (r, u, 1);
+  mpz_neg (r, r);
 }
 
 void
diff -r afae8fd2739d -r 0b950ea75d42 mini-gmp/tests/t-bitops.c
--- a/mini-gmp/tests/t-bitops.c	Wed Dec 12 04:02:51 2018 +0100
+++ b/mini-gmp/tests/t-bitops.c	Sat Dec 15 08:07:13 2018 +0100
@@ -79,6 +79,7 @@
 	}
       mini_random_bit_op (OP_COMBIT, MAXBITS, a, &b, ref);
       mpz_set (res, a);
+      mpz_com (a, a);
       mpz_combit (res, b);
       if (mpz_cmp (res, ref))
 	{
@@ -89,7 +90,7 @@
 	  dump ("ref", ref);
 	  abort ();
 	}
-      if (mpz_tstbit (res, b) == mpz_tstbit (a, b))
+      if (mpz_tstbit (res, b) != mpz_tstbit (a, b))
 	{
 	  fprintf (stderr, "mpz_tstbit failed (after mpz_combit):\n");
 	  dump ("res", a);


More information about the gmp-commit mailing list