mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
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:
1 parent
a9a8e0db47
commit
86bddb0d53
2 files changed
+3
-5
No files matched your search
+2
-2
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user