mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Fix compilation on ppc64
This commit is contained in:
@ -755,6 +755,9 @@ struct is_fast_float : bool_constant<std::numeric_limits<T>::is_iec559 &&
|
|||||||
sizeof(T) <= sizeof(double)> {};
|
sizeof(T) <= sizeof(double)> {};
|
||||||
template <typename T> struct is_fast_float<T, false> : std::false_type {};
|
template <typename T> struct is_fast_float<T, false> : std::false_type {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using is_double_double = bool_constant<std::numeric_limits<T>::digits == 106>;
|
||||||
|
|
||||||
#ifndef FMT_USE_FULL_CACHE_DRAGONBOX
|
#ifndef FMT_USE_FULL_CACHE_DRAGONBOX
|
||||||
# define FMT_USE_FULL_CACHE_DRAGONBOX 0
|
# define FMT_USE_FULL_CACHE_DRAGONBOX 0
|
||||||
#endif
|
#endif
|
||||||
@ -1314,15 +1317,9 @@ struct float_info<T, enable_if_t<std::numeric_limits<T>::digits == 64 ||
|
|||||||
static const int exponent_bits = 15;
|
static const int exponent_bits = 15;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <int> constexpr int check_digits();
|
|
||||||
|
|
||||||
// A double-double floating point number.
|
// A double-double floating point number.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct float_info<T, enable_if_t<!(std::numeric_limits<T>::digits == 64 ||
|
struct float_info<T, enable_if_t<is_double_double<T>::value>> {
|
||||||
std::numeric_limits<T>::digits == 113 ||
|
|
||||||
is_float128<T>::value) &&
|
|
||||||
std::is_same<T, long double>::value>> {
|
|
||||||
static constexpr int check = check_digits<std::numeric_limits<T>::digits>();
|
|
||||||
using carrier_uint = detail::uint128_t;
|
using carrier_uint = detail::uint128_t;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1400,8 +1397,7 @@ template <typename F> struct basic_fp {
|
|||||||
template <typename Float> FMT_CONSTEXPR basic_fp(Float n) { assign(n); }
|
template <typename Float> FMT_CONSTEXPR basic_fp(Float n) { assign(n); }
|
||||||
|
|
||||||
// Assigns n to this and return true iff predecessor is closer than successor.
|
// Assigns n to this and return true iff predecessor is closer than successor.
|
||||||
template <typename Float,
|
template <typename Float, FMT_ENABLE_IF(!is_double_double<Float>::value)>
|
||||||
FMT_ENABLE_IF(std::numeric_limits<Float>::is_iec559)>
|
|
||||||
FMT_CONSTEXPR auto assign(Float n) -> bool {
|
FMT_CONSTEXPR auto assign(Float n) -> bool {
|
||||||
static_assert(std::numeric_limits<Float>::digits <= 113, "unsupported FP");
|
static_assert(std::numeric_limits<Float>::digits <= 113, "unsupported FP");
|
||||||
// Assume Float is in the format [sign][exponent][significand].
|
// Assume Float is in the format [sign][exponent][significand].
|
||||||
@ -1426,8 +1422,7 @@ template <typename F> struct basic_fp {
|
|||||||
return is_predecessor_closer;
|
return is_predecessor_closer;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Float,
|
template <typename Float, FMT_ENABLE_IF(is_double_double<Float>::value)>
|
||||||
FMT_ENABLE_IF(!std::numeric_limits<Float>::is_iec559)>
|
|
||||||
FMT_CONSTEXPR auto assign(Float n) -> bool {
|
FMT_CONSTEXPR auto assign(Float n) -> bool {
|
||||||
static_assert(std::numeric_limits<double>::is_iec559, "unsupported FP");
|
static_assert(std::numeric_limits<double>::is_iec559, "unsupported FP");
|
||||||
return assign(static_cast<double>(n));
|
return assign(static_cast<double>(n));
|
||||||
|
@ -379,17 +379,17 @@ bool operator>=(const double_double& lhs, const double_double& rhs) {
|
|||||||
namespace std {
|
namespace std {
|
||||||
template <> struct is_floating_point<double_double> : std::true_type {};
|
template <> struct is_floating_point<double_double> : std::true_type {};
|
||||||
template <> struct numeric_limits<double_double> {
|
template <> struct numeric_limits<double_double> {
|
||||||
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;
|
static constexpr int digits = 106;
|
||||||
};
|
};
|
||||||
} // namespace std
|
} // namespace std
|
||||||
|
|
||||||
TEST(format_impl_test, write_double_double) {
|
TEST(format_impl_test, write_double_double) {
|
||||||
// TODO: restore
|
auto s = std::string();
|
||||||
// auto s = std::string();
|
fmt::detail::write<char>(std::back_inserter(s), double_double(42), {});
|
||||||
// fmt::detail::write<char>(std::back_inserter(s), double_double(42), {});
|
|
||||||
#ifndef _MSC_VER // MSVC has an issue with specializing is_floating_point.
|
#ifndef _MSC_VER // MSVC has an issue with specializing is_floating_point.
|
||||||
// EXPECT_EQ(s, "42");
|
EXPECT_EQ(s, "42");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1984,7 +1984,7 @@ TEST(format_test, to_string) {
|
|||||||
EXPECT_EQ(fmt::to_string(zero), "0");
|
EXPECT_EQ(fmt::to_string(zero), "0");
|
||||||
|
|
||||||
#if FMT_USE_FLOAT128
|
#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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user