From 9d6039595302a6d6fe4cb2b8bfe98e9b09ed559b Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Tue, 31 May 2022 12:47:08 -0700 Subject: [PATCH] Fix compilation on ppc64 --- include/fmt/format.h | 17 ++++++----------- test/format-impl-test.cc | 10 +++++----- test/format-test.cc | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index cc5b2e37..37bca46d 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -755,6 +755,9 @@ struct is_fast_float : bool_constant::is_iec559 && sizeof(T) <= sizeof(double)> {}; template struct is_fast_float : std::false_type {}; +template +using is_double_double = bool_constant::digits == 106>; + #ifndef FMT_USE_FULL_CACHE_DRAGONBOX # define FMT_USE_FULL_CACHE_DRAGONBOX 0 #endif @@ -1314,15 +1317,9 @@ struct float_info::digits == 64 || static const int exponent_bits = 15; }; -template constexpr int check_digits(); - // A double-double floating point number. template -struct float_info::digits == 64 || - std::numeric_limits::digits == 113 || - is_float128::value) && - std::is_same::value>> { - static constexpr int check = check_digits::digits>(); +struct float_info::value>> { using carrier_uint = detail::uint128_t; }; @@ -1400,8 +1397,7 @@ template struct basic_fp { template FMT_CONSTEXPR basic_fp(Float n) { assign(n); } // Assigns n to this and return true iff predecessor is closer than successor. - template ::is_iec559)> + template ::value)> FMT_CONSTEXPR auto assign(Float n) -> bool { static_assert(std::numeric_limits::digits <= 113, "unsupported FP"); // Assume Float is in the format [sign][exponent][significand]. @@ -1426,8 +1422,7 @@ template struct basic_fp { return is_predecessor_closer; } - template ::is_iec559)> + template ::value)> FMT_CONSTEXPR auto assign(Float n) -> bool { static_assert(std::numeric_limits::is_iec559, "unsupported FP"); return assign(static_cast(n)); diff --git a/test/format-impl-test.cc b/test/format-impl-test.cc index b231f556..b210e979 100644 --- a/test/format-impl-test.cc +++ b/test/format-impl-test.cc @@ -379,17 +379,17 @@ bool operator>=(const double_double& lhs, const double_double& rhs) { namespace std { template <> struct is_floating_point : std::true_type {}; template <> struct numeric_limits { - static constexpr bool is_iec559 = false; + // is_iec559 is true for double-double in libstdc++. + static constexpr bool is_iec559 = true; static constexpr int digits = 106; }; } // namespace std TEST(format_impl_test, write_double_double) { - // TODO: restore - // auto s = std::string(); - // fmt::detail::write(std::back_inserter(s), double_double(42), {}); + auto s = std::string(); + fmt::detail::write(std::back_inserter(s), double_double(42), {}); #ifndef _MSC_VER // MSVC has an issue with specializing is_floating_point. - // EXPECT_EQ(s, "42"); + EXPECT_EQ(s, "42"); #endif } diff --git a/test/format-test.cc b/test/format-test.cc index d32a2491..526174a7 100644 --- a/test/format-test.cc +++ b/test/format-test.cc @@ -1984,7 +1984,7 @@ TEST(format_test, to_string) { EXPECT_EQ(fmt::to_string(zero), "0"); #if FMT_USE_FLOAT128 - EXPECT_EQ(fmt::to_string(__float128(0.42)), "0.42"); + EXPECT_EQ(fmt::to_string(__float128(0.5)), "0.5"); #endif }