From 8d6bedda361fdefc82a3310503e698582ce429ec Mon Sep 17 00:00:00 2001 From: Matt Borland Date: Wed, 17 Jul 2024 13:18:58 -0400 Subject: [PATCH] Improve operator >= --- include/boost/decimal/decimal32_fast.hpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/include/boost/decimal/decimal32_fast.hpp b/include/boost/decimal/decimal32_fast.hpp index aef560447..8ac613880 100644 --- a/include/boost/decimal/decimal32_fast.hpp +++ b/include/boost/decimal/decimal32_fast.hpp @@ -560,13 +560,29 @@ constexpr auto operator>(decimal32_fast lhs, decimal32_fast rhs) noexcept -> boo constexpr auto operator>=(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool { #ifndef BOOST_DECIMAL_FAST_MATH - if (isnan(lhs) || isnan(rhs)) + if (!isfinite(lhs) || !isfinite(rhs)) { - return false; + if (isnan(lhs) || isnan(rhs)) + { + return false; + } + else if (lhs.isneg() && !rhs.isneg()) + { + return false; + } + else if (isfinite(lhs) && isinf(rhs)) + { + return signbit(rhs); + } + else if (isinf(lhs) && isfinite(rhs)) + { + return !signbit(lhs); + } } #endif - return !(lhs < rhs); + return !fast_type_less_parts_impl(lhs.significand_, lhs.biased_exponent(), lhs.sign_, + rhs.significand_, rhs.biased_exponent(), rhs.sign_); } template