diff --git a/configure b/configure index 864c2373..5b84762c 100755 --- a/configure +++ b/configure @@ -19563,6 +19563,13 @@ then : fi +ac_fn_cxx_check_header_compile "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default" +if test "x$ac_cv_header_stdint_h" = xyes +then : + printf "%s\n" "#define HAVE_STDINT_H 1" >>confdefs.h + +fi + ############################################################################ # Data type and math function definitions # diff --git a/configure.ac b/configure.ac index f35c2294..a5804ec4 100644 --- a/configure.ac +++ b/configure.ac @@ -52,6 +52,7 @@ AC_COIN_DEBUGLEVEL AC_CHECK_HEADERS([windows.h]) AC_CHECK_HEADERS([endian.h]) AC_CHECK_HEADERS([execinfo.h]) +AC_CHECK_HEADERS([stdint.h]) ############################################################################ # Data type and math function definitions # diff --git a/src/CoinRational.cpp b/src/CoinRational.cpp index 70ff289a..ddf8a956 100644 --- a/src/CoinRational.cpp +++ b/src/CoinRational.cpp @@ -2,6 +2,8 @@ // Copyright 2015, Matthew Saltzman and Ted Ralphs // Licensed under the Eclipse Public License +#include "CoinUtilsConfig.h" + #include #include #ifdef __clang__ @@ -10,6 +12,9 @@ #include #endif #include +#ifdef COINUTILS_HAS_STDINT_H +#include +#endif #include "CoinRational.hpp" @@ -20,7 +25,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 +36,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 +88,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/CoinRational.hpp b/src/CoinRational.hpp index 35d92f3c..e73d5e9a 100644 --- a/src/CoinRational.hpp +++ b/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 @@ class COINUTILSLIB_EXPORT CoinRational }; 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