Skip to content

Commit

Permalink
Improve operator<=
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Jul 16, 2024
1 parent 453114e commit 9ffb696
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions include/boost/decimal/decimal32_fast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,13 +526,30 @@ 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) ||
(!lhs.isneg() && rhs.isneg()))
{
return false;
}
else if (lhs.isneg() && !rhs.isneg())
{
return true;
}
else if (isfinite(lhs) && isinf(rhs))
{
return !signbit(rhs);
}
else if (isinf(lhs) && isfinite(rhs))
{
return signbit(rhs);
}
}
#endif

return !(rhs < lhs);
return !fast_type_less_parts_impl(rhs.significand_, rhs.biased_exponent(), rhs.sign_,
lhs.significand_, lhs.biased_exponent(), lhs.sign_);
}

constexpr auto operator>(decimal32_fast lhs, decimal32_fast rhs) noexcept -> bool
Expand Down

0 comments on commit 9ffb696

Please sign in to comment.