From 64797e777b13907e2e8c0b095082ad017c8e5d6d Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Thu, 23 Jan 2025 13:28:31 -0500 Subject: [PATCH] Reduce d64_fast isnan to a single comparison --- include/boost/decimal/decimal64_fast.hpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/include/boost/decimal/decimal64_fast.hpp b/include/boost/decimal/decimal64_fast.hpp index 4b7d99fe..ed7ec571 100644 --- a/include/boost/decimal/decimal64_fast.hpp +++ b/include/boost/decimal/decimal64_fast.hpp @@ -31,9 +31,9 @@ namespace decimal { namespace detail { -BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_inf = std::numeric_limits::max(); -BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_qnan = std::numeric_limits::max() - 1; -BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_snan = std::numeric_limits::max() - 2; +BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_inf = std::numeric_limits::max() - 3; +BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_qnan = std::numeric_limits::max() - 2; +BOOST_DECIMAL_CONSTEXPR_VARIABLE auto d64_fast_snan = std::numeric_limits::max() - 1; struct decimal64_fast_components { @@ -479,8 +479,7 @@ constexpr auto isinf(decimal64_fast val) noexcept -> bool constexpr auto isnan(decimal64_fast val) noexcept -> bool { #ifndef BOOST_DECIMAL_FAST_MATH - return val.significand_ == detail::d64_fast_qnan || - val.significand_ == detail::d64_fast_snan; + return val.significand_ >= detail::d64_fast_qnan; #else static_cast(val); return false; @@ -513,12 +512,12 @@ constexpr auto isnormal(decimal64_fast val) noexcept -> bool constexpr auto isfinite(decimal64_fast val) noexcept -> bool { - return val.significand_ < detail::d64_fast_snan; + return val.significand_ < detail::d64_fast_inf; } constexpr auto not_finite(decimal64_fast val) noexcept -> bool { - return val.significand_ >= detail::d64_fast_snan; + return val.significand_ >= detail::d64_fast_inf; } constexpr auto operator==(decimal64_fast lhs, decimal64_fast rhs) noexcept -> bool