mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-11-19 02:22:10 -05:00
Use ULLONG_MAX instead of U_LONG_LONG_MAX.
git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6219 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
0ca7c9797e
commit
f0c01470bb
@ -23,11 +23,11 @@ unsigned long long binomial(unsigned long long n, unsigned long long k) {
|
||||
if (k >= n) return (k == n);
|
||||
if (k > n/2) k = n-k;
|
||||
for (d = 1; d <= k; d++) {
|
||||
if (r >= ULONG_LONG_MAX/n) { /* Possible overflow */
|
||||
if (r >= ULLONG_MAX/n) { /* Possible overflow */
|
||||
unsigned long long nr, dr; /* reduced numerator / denominator */
|
||||
g = gcd_ui(n, d); nr = n/g; dr = d/g;
|
||||
g = gcd_ui(r, dr); r = r/g; dr = dr/g;
|
||||
if (r >= ULONG_LONG_MAX/nr) return 0; /* Unavoidable overflow */
|
||||
if (r >= ULLONG_MAX/nr) return 0; /* Unavoidable overflow */
|
||||
r *= nr;
|
||||
r /= dr;
|
||||
n--;
|
||||
|
Loading…
Reference in New Issue
Block a user