Skip to content

Commit 9aa0d2d

Browse files
committed
Fix comp of zero for decimal32
1 parent dd1c6e1 commit 9aa0d2d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

include/boost/decimal/detail/comparison.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ BOOST_DECIMAL_FORCE_INLINE constexpr auto equality_impl(DecimalType lhs, Decimal
5757

5858
const auto delta_exp {lhs_exp - rhs_exp};
5959

60-
if (delta_exp > detail::precision_v<DecimalType> || delta_exp < -detail::precision_v<DecimalType> ||
61-
((lhs_sig == static_cast<comp_type>(0)) ^ (rhs_sig == static_cast<comp_type>(0))))
60+
if (lhs_sig == 0 && rhs_sig == 0)
61+
{
62+
// The difference in exponent is irrelevant here
63+
return true;
64+
}
65+
if (delta_exp > detail::precision_v<DecimalType> || delta_exp < -detail::precision_v<DecimalType>)
6266
{
6367
return false;
6468
}

0 commit comments

Comments
 (0)