factor: define SQUARE_OF_FIRST_OMITTED_PRIME

* src/make-prime-list.c (output_primes): Output
SQUARE_OF_FIRST_OMITTED_PRIME, not FIRST_OMITTED_PRIME.  All uses
changed.  This way, the uses don’t need to worry about casts to
avoid overflow.
This commit is contained in:
Paul Eggert committed 2025-07-09 17:12:40 -07:00
1 parent a9a8e0db47
commit 86bddb0d53
2 files changed
+3 -5

No files matched your search

+2 -2
View File
@@ -1348,7 +1348,7 @@ prime_p (mp_limb_t n)
return false;
/* We have already cast out small primes. */
if (n < (mp_limb_t) FIRST_OMITTED_PRIME * FIRST_OMITTED_PRIME)
if (n < SQUARE_OF_FIRST_OMITTED_PRIME)
return true;
if (USE_BAILLIE_PSW)
@@ -1540,7 +1540,7 @@ mp_prime_p (mpz_t n)
return false;
/* We have already cast out small primes. */
if (mpz_cmp_ui (n, (long) FIRST_OMITTED_PRIME * FIRST_OMITTED_PRIME) < 0)
if (mpz_cmp_ui (n, SQUARE_OF_FIRST_OMITTED_PRIME) < 0)
return true;
int probab_prime = mpz_probab_prime_p (n, MR_REPS);
+1 -3
View File
@@ -150,8 +150,6 @@ output_primes (const struct prime *primes, unsigned nprimes)
p = primes[i].p;
}
printf ("\n#undef FIRST_OMITTED_PRIME\n");
/* Find next prime */
do
{
@@ -169,7 +167,7 @@ output_primes (const struct prime *primes, unsigned nprimes)
}
while (!is_prime);
printf ("#define FIRST_OMITTED_PRIME %u\n", p);
printf ("#define SQUARE_OF_FIRST_OMITTED_PRIME %u\n", p * p);
}
ATTRIBUTE_MALLOC