Skip to content

Commit 8d6bedd

Browse files
committed
Improve operator >=
1 parent 9ffb696 commit 8d6bedd

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

include/boost/decimal/decimal32_fast.hpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,29 @@ constexpr auto operator>(decimal32_fast lhs, decimal32_fast rhs) noexcept -> boo
560560
constexpr auto operator>=(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool
561561
{
562562
#ifndef BOOST_DECIMAL_FAST_MATH
563-
if (isnan(lhs) || isnan(rhs))
563+
if (!isfinite(lhs) || !isfinite(rhs))
564564
{
565-
return false;
565+
if (isnan(lhs) || isnan(rhs))
566+
{
567+
return false;
568+
}
569+
else if (lhs.isneg() && !rhs.isneg())
570+
{
571+
return false;
572+
}
573+
else if (isfinite(lhs) && isinf(rhs))
574+
{
575+
return signbit(rhs);
576+
}
577+
else if (isinf(lhs) && isfinite(rhs))
578+
{
579+
return !signbit(lhs);
580+
}
566581
}
567582
#endif
568583

569-
return !(lhs < rhs);
584+
return !fast_type_less_parts_impl(lhs.significand_, lhs.biased_exponent(), lhs.sign_,
585+
rhs.significand_, rhs.biased_exponent(), rhs.sign_);
570586
}
571587

572588
template <typename Integer>

0 commit comments

Comments
 (0)