diff --git a/src/Cgl/src/CglPreProcess/CglPreProcess.cpp b/src/Cgl/src/CglPreProcess/CglPreProcess.cpp index 60e4584..ba05c2f 100644 --- a/src/Cgl/src/CglPreProcess/CglPreProcess.cpp +++ b/src/Cgl/src/CglPreProcess/CglPreProcess.cpp @@ -1183,13 +1183,13 @@ static void writeDebugMps(const OsiSolverInterface *solver, #define USE_CGL_RATIONAL 1 #if USE_CGL_RATIONAL>0 #include "CoinRational.hpp" -static long computeGcd(long a, long b) { +static int64_t computeGcd(int64_t a, int64_t b) { // This is the standard Euclidean algorithm for gcd - long remainder = 1; + int64_t remainder = 1; // Make sure a<=b (will always remain so) if (a > b) { // Swap a and b - long temp = a; + int64_t temp = a; a = b; b = temp; } @@ -1212,15 +1212,15 @@ static long computeGcd(long a, long b) { } /* computeGcd */ static bool scaleRowIntegral(double* rowElem, int rowNz) { - long gcd, lcm; + int64_t gcd, lcm; double maxdelta = 1.0e-13; double maxscale = 1000; - long maxdnom = 1000; - //long numerator = 0, denominator = 0; + int64_t maxdnom = 1000; + //int64_t numerator = 0, denominator = 0; // Initialize gcd and lcm CoinRational r = CoinRational(rowElem[0], maxdelta, maxdnom); if (r.getNumerator() != 0){ - gcd = labs(r.getNumerator()); + gcd = llabs(r.getNumerator()); lcm = r.getDenominator(); } else { return false; diff --git a/src/CoinUtils/src/CoinRational.cpp b/src/CoinUtils/src/CoinRational.cpp index 70ff289..1db5fb3 100644 --- a/src/CoinUtils/src/CoinRational.cpp +++ b/src/CoinUtils/src/CoinRational.cpp @@ -20,7 +20,7 @@ // Returns closest (or almost, anyway) rational to val with denominator less // than or equal to maxdnom. Return value is true if within tolerance, false // otherwise. -bool CoinRational::nearestRational_(double val, double maxdelta, long maxdnom) +bool CoinRational::nearestRational_(double val, double maxdelta, int64_t maxdnom) { double intpart; if (floor(val)==val) { @@ -31,7 +31,7 @@ bool CoinRational::nearestRational_(double val, double maxdelta, long maxdnom) double fracpart = fabs(modf(val, &intpart)); // Consider using remainder() instead? - long a = 0, b = 1, c = 1, d = 1; + int64_t a = 0, b = 1, c = 1, d = 1; #define DEBUG_X 1 #if DEBUG_X bool shouldBeOK = false; @@ -83,7 +83,7 @@ bool CoinRational::nearestRational_(double val, double maxdelta, long maxdnom) numerator_ *= -1; #if DEBUG_X > 1 if (shouldBeOK) { - printf("val %g is %ld/%ld to accuracy %g\n", val, numerator_, denominator_, + printf("val %g is %lld/%lld to accuracy %g\n", val, numerator_, denominator_, fabs(val - numerator_ / double(denominator_))); } #endif diff --git a/src/CoinUtils/src/CoinRational.hpp b/src/CoinUtils/src/CoinRational.hpp index 35d92f3..e73d5e9 100644 --- a/src/CoinUtils/src/CoinRational.hpp +++ b/src/CoinUtils/src/CoinRational.hpp @@ -14,18 +14,18 @@ class COINUTILSLIB_EXPORT CoinRational { public: - long getDenominator() { return denominator_; } - long getNumerator() { return numerator_; } + int64_t getDenominator() { return denominator_; } + int64_t getNumerator() { return numerator_; } CoinRational() : numerator_(0) , denominator_(1) {}; - CoinRational(long n, long d) + CoinRational(int64_t n, int64_t d) : numerator_(n) , denominator_(d) {}; - CoinRational(double val, double maxdelta, long maxdnom) + CoinRational(double val, double maxdelta, int64_t maxdnom) { if (!nearestRational_(val, maxdelta, maxdnom)) { numerator_ = 0; @@ -34,10 +34,10 @@ public: }; private: - long numerator_; - long denominator_; + int64_t numerator_; + int64_t denominator_; - bool nearestRational_(double val, double maxdelta, long maxdnom); + bool nearestRational_(double val, double maxdelta, int64_t maxdnom); }; #endif