diff --git a/cmake/cpp.cmake b/cmake/cpp.cmake index daf6ba7eb8..6ed05026d6 100644 --- a/cmake/cpp.cmake +++ b/cmake/cpp.cmake @@ -81,6 +81,7 @@ if(MSVC) "/MP" # Build with multiple processes "/Zc:preprocessor" # Enable preprocessor conformance mode "/DNDEBUG" + "/fp:precise" ) # MSVC warning suppressions list(APPEND OR_TOOLS_COMPILE_OPTIONS diff --git a/ortools/util/fp_utils.h b/ortools/util/fp_utils.h index 2cfee51ccf..e9e0546449 100644 --- a/ortools/util/fp_utils.h +++ b/ortools/util/fp_utils.h @@ -22,25 +22,26 @@ #ifndef OR_TOOLS_UTIL_FP_UTILS_H_ #define OR_TOOLS_UTIL_FP_UTILS_H_ +#include +#include +#include +#include +#include // must be call before fenv_access see: https://github.com/microsoft/STL/issues/2613 +#include + +#include "absl/log/check.h" + #if defined(_MSC_VER) #pragma fenv_access(on) // NOLINT #else -#include // NOLINT +#include // NOLINT #endif #ifdef __SSE__ #include #endif -#include - -#include -#include -#include -#include - #include "ortools/base/integral_types.h" -#include "ortools/base/logging.h" #if defined(_MSC_VER) static inline double isnan(double value) { return _isnan(value); } @@ -229,8 +230,7 @@ double GetBestScalingOfDoublesToInt64(const std::vector& input, // scaling_factor to have the maximum absolute error on the original sum. void ComputeScalingErrors(const std::vector& input, const std::vector& lb, - const std::vector& ub, - const double scaling_factor, + const std::vector& ub, double scaling_factor, double* max_relative_coeff_error, double* max_scaled_sum_error); @@ -250,15 +250,15 @@ inline FloatType Interpolate(FloatType x, FloatType y, FloatType alpha) { // This is a fast implementation of the C99 function ilogb for normalized // doubles with the caveat that it returns -1023 for zero, and 1024 for infinity // an NaNs. -int fast_ilogb(const double value); +int fast_ilogb(double value); // This is a fast implementation of the C99 function scalbn, with the caveat // that it works on normalized numbers and if the result underflows, overflows, // or is applied to a NaN or an +-infinity, the result is undefined behavior. // Note that the version of the function that takes a reference, modifies the // given value. -double fast_scalbn(const double value, const int exponent); -void fast_scalbn_inplace(double& mutable_value, const int exponent); +double fast_scalbn(double value, int exponent); +void fast_scalbn_inplace(double& mutable_value, int exponent); } // namespace operations_research