diff --git a/src/core/model/int64x64-128.h b/src/core/model/int64x64-128.h index 0c2a068b3..3b0c89afe 100644 --- a/src/core/model/int64x64-128.h +++ b/src/core/model/int64x64-128.h @@ -58,22 +58,11 @@ class int64x64_t static const uint128_t HP128_MASK_HI_BIT = (((int128_t)1) << 127); /// Mask for fraction part. static const uint64_t HP_MASK_LO = 0xffffffffffffffffULL; - /** - * Floating point value of HP_MASK_LO + 1. - * We really want: - * \code - * static const long double HP_MAX_64 = std:pow (2.0L, 64); - * \endcode - * but we can't call functions in const definitions. - * - * We could make this a static and initialize in int64x64-128.cc or - * int64x64.cc, but this requires handling static initialization order - * when most of the implementation is inline. Instead, we resort to - * this define. - */ -#define HP_MAX_64 (std::pow(2.0L, 64)) public: + /// Floating point value of HP_MASK_LO + 1. + static constexpr long double HP_MAX_64 = (static_cast(1) << 63) * 2.0L; + /** * Type tag for the underlying implementation. * diff --git a/src/core/model/int64x64-cairo.h b/src/core/model/int64x64-cairo.h index e90d4d120..c0769b79f 100644 --- a/src/core/model/int64x64-cairo.h +++ b/src/core/model/int64x64-cairo.h @@ -44,21 +44,11 @@ class int64x64_t static const uint64_t HPCAIRO_MASK_HI_BIT = (((uint64_t)1) << 63); /// Mask for fraction part static const uint64_t HP_MASK_LO = 0xffffffffffffffffULL; - /** - * Floating point value of HP_MASK_LO + 1 - * We really want: - * \code - * static const long double HP_MAX_64 = std:pow (2.0L, 64); - * \endcode - * but we can't call functions in const definitions, - * We could make this a static and initialize in int64x64-cairo.cc or - * int64x64.cc, but this requires handling static initialization order - * when most of the implementation is inline. Instead, we resort to - * this define. - */ -#define HP_MAX_64 (std::pow(2.0L, 64)) public: + /// Floating point value of HP_MASK_LO + 1 + static constexpr long double HP_MAX_64 = (static_cast(1) << 63) * 2.0L; + /** * Type tag for the underlying implementation. * diff --git a/src/core/model/int64x64-double.h b/src/core/model/int64x64-double.h index b965003c1..2f78c65f3 100644 --- a/src/core/model/int64x64-double.h +++ b/src/core/model/int64x64-double.h @@ -43,21 +43,11 @@ class int64x64_t { /// Mask for fraction part static const uint64_t HP_MASK_LO = 0xffffffffffffffffULL; - /** - * Floating point value of HP_MASK_LO + 1 - * We really want: - * \code - * static const long double HP_MAX_64 = std:pow (2.0L, 64); - * \endcode - * but we can't call functions in const definitions, - * We could make this a static and initialize in int64x64-double.cc or - * int64x64.cc, but this requires handling static initialization order - * when most of the implementation is inline. Instead, we resort to - * this define. - */ -#define HP_MAX_64 (std::pow(2.0L, 64)) public: + /// Floating point value of HP_MASK_LO + 1 + static constexpr long double HP_MAX_64 = (static_cast(1) << 63) * 2.0L; + /** * Type tag for the underlying implementation. * diff --git a/src/core/test/int64x64-test-suite.cc b/src/core/test/int64x64-test-suite.cc index 877a965e8..43118875c 100644 --- a/src/core/test/int64x64-test-suite.cc +++ b/src/core/test/int64x64-test-suite.cc @@ -182,7 +182,8 @@ Int64x64HiLoTestCase::DoRun() if (int64x64_t::implementation == int64x64_t::ld_impl) { // Darwin 12.5.0 (Mac 10.8.5) g++ 4.2.1 - low = static_cast(HP_MAX_64 * std::numeric_limits::epsilon()); + low = static_cast(int64x64_t::HP_MAX_64 * + std::numeric_limits::epsilon()); } Check(0, 0);