stronglucas.c
Seth Troisi
braintwo at gmail.com
Thu May 12 23:55:03 CEST 2022
I was reading the stronglucas code and I think this small change may
improve clarity
diff -r 970b7221873f mpz/stronglucas.c
--- a/mpz/stronglucas.c Mon Nov 16 19:48:04 2020 +0100
+++ b/mpz/stronglucas.c Thu May 12 14:10:15 2022 -0700
@@ -134,7 +134,7 @@
int jac;
/* n is odd, to possibly be a square, n % 8 = 1 is needed. */
- if (((*PTR (n) & 6) == 0) && UNLIKELY (mpz_perfect_square_p (n)))
+ if (((*PTR (n) & 7) == 1) && UNLIKELY (mpz_perfect_square_p (n)))
return 0; /* A square is composite. */
/* Check Ds up to square root (in case, n is prime)
Technically n/x should be odd per the function comment but IMO this
improves readability by having the "n % 8 = 1" in the nearer comment match
the code.
It's also possible lines 122-124 should also be indented
More information about the gmp-devel
mailing list