Skip to content

Commit eb8448d

Browse files
committed
Simplify operator<
1 parent a5ce26c commit eb8448d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

include/boost/decimal/decimal128_fast.hpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,8 +546,17 @@ constexpr auto operator<(const decimal128_fast& lhs, const decimal128_fast& rhs)
546546
}
547547
#endif
548548

549-
return less_parts_impl<decimal128>(lhs.significand_, lhs.biased_exponent(), lhs.sign_,
550-
rhs.significand_, rhs.biased_exponent(), rhs.sign_);
549+
if (lhs.significand_ == 0 || rhs.significand_ == 0)
550+
{
551+
return lhs.significand_ == 0 ? !rhs.sign_ : lhs.sign_;
552+
}
553+
554+
if (lhs.exponent_ != rhs.exponent_)
555+
{
556+
return lhs.sign_ ? lhs.exponent_ > rhs.exponent_ : lhs.exponent_ < rhs.exponent_;
557+
}
558+
559+
return lhs.sign_ ? lhs.significand_ > rhs.significand_ : lhs.significand_ < rhs.significand_;
551560
}
552561

553562
template <typename Integer>

0 commit comments

Comments
 (0)