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:
Joe Taylor 2015-12-02 16:43:03 +00:00
parent 0ca7c9797e
commit f0c01470bb

View File

@ -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--;