diff --git a/include/fmt/format.h b/include/fmt/format.h index 59b8077b..ac0e5aab 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2293,10 +2293,14 @@ FMT_CONSTEXPR20 auto write_float(OutputIt out, const DecimalFP& fp, } } +template constexpr bool isnan(T value) { + return !(value >= value); // std::isnan doesn't support __float128. +} + template ::value && !is_float128::value)> FMT_CONSTEXPR20 bool isfinite(T value) { - if (is_constant_evaluated()) return value - value == 0; + if (is_constant_evaluated()) return !isnan(value - value); return std::isfinite(value); } template ::value)> @@ -2304,10 +2308,6 @@ constexpr bool isfinite(T value) { return value - value == 0; // std::isfinite doesn't support __float128. } -template constexpr bool isnan(T value) { - return value != value; // std::isnan doesn't support __float128. -} - template ::value)> FMT_INLINE FMT_CONSTEXPR bool signbit(T value) { if (is_constant_evaluated()) {