Mercurial > octave
changeset 31399:4dc9230db992
__isprimelarge__.cc: Avoid explicit use of "unsigned long long" literals.
* libinterp/corefcn/__isprimelarge__.cc (pollardrho): Avoid potential issues on
platforms that don't have an "unsigned long long" data type.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 06 Nov 2022 12:18:37 +0100 |
parents | 4f86d56c090d |
children | e7fc6251b698 |
files | libinterp/corefcn/__isprimelarge__.cc |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/__isprimelarge__.cc Sat Nov 05 18:35:09 2022 -0400 +++ b/libinterp/corefcn/__isprimelarge__.cc Sun Nov 06 12:18:37 2022 +0100 @@ -213,9 +213,9 @@ // factorization algorithm with Brent update. // The code is short and simple, but the math behind it is complicated. uint64_t -pollardrho (uint64_t n, uint64_t c = 1ULL) +pollardrho (uint64_t n, uint64_t c = UINT64_C (1)) { - uint64_t i = 1ULL, j = 2ULL; // cycle index values + uint64_t i = UINT64_C (1), j = UINT64_C (2); // cycle index values uint64_t x = (c+1) % n; // can also be rand () % n uint64_t y = x; // other value in the chain uint64_t g = 0; // GCD @@ -238,10 +238,10 @@ j <<= 1; } - if (g == n || i > 1000000ULL) // cut losses, restart with a different c + if (g == n || i > UINT64_C (1000000)) // cut losses, restart with a different c return pollardrho (n, c + 2); - if (g > 1ULL) // found GCD ==> exit loop properly + if (g > UINT64_C (1)) // found GCD ==> exit loop properly { error_unless (n % g == 0); // theoretical possibility of GCD error return g;