Skip to content

Commit bdfa306

Browse files
committed
Improve u128 zero removal for case <= UINT64_MAX
1 parent 6d38e19 commit bdfa306

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

include/boost/decimal/detail/remove_trailing_zeros.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,15 @@ constexpr auto remove_trailing_zeros(std::uint64_t n) noexcept -> remove_trailin
8585
return {n, s};
8686
}
8787

88-
// TODO(mborland): Make this better. Check lower word for equal to 0.
88+
// TODO(mborland): Make this better for the 2-word case
8989
constexpr auto remove_trailing_zeros(uint128 n) noexcept -> remove_trailing_zeros_return<uint128>
9090
{
91+
if (n.high == UINT64_C(0))
92+
{
93+
const auto temp {remove_trailing_zeros(n.low)};
94+
return {static_cast<uint128>(temp.trimmed_number), temp.number_of_removed_zeros};
95+
}
96+
9197
std::size_t s {};
9298

9399
while (n % 10 == 0)

0 commit comments

Comments
 (0)