Skip to content

Commit ce5cea3

Browse files
committed
Simplifications
1 parent 72b1e56 commit ce5cea3

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

include/boost/decimal/detail/add_impl.hpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <boost/decimal/detail/components.hpp>
1212
#include <boost/decimal/detail/power_tables.hpp>
1313
#include <boost/decimal/detail/promotion.hpp>
14+
#include <boost/decimal/detail/is_power_of_10.hpp>
1415
#include "int128.hpp"
1516

1617
#ifndef BOOST_DECIMAL_BUILD_MODULE
@@ -76,8 +77,7 @@ constexpr auto add_impl(const T& lhs, const T& rhs) noexcept -> ReturnType
7677
{
7778
if (big_rhs != 0U && (lhs.isneg() != rhs.isneg()))
7879
{
79-
const auto removed_zeros {detail::remove_trailing_zeros(big_lhs)};
80-
if (removed_zeros.trimmed_number == 1U)
80+
if (is_power_of_10(big_lhs))
8181
{
8282
--big_lhs;
8383
big_lhs *= 10U;
@@ -96,8 +96,7 @@ constexpr auto add_impl(const T& lhs, const T& rhs) noexcept -> ReturnType
9696
{
9797
if (big_lhs != 0U && (lhs.isneg() != rhs.isneg()))
9898
{
99-
const auto removed_zeros {detail::remove_trailing_zeros(big_rhs)};
100-
if (removed_zeros.trimmed_number == 1U)
99+
if (is_power_of_10(big_rhs))
101100
{
102101
--big_rhs;
103102
big_rhs *= 10U;
@@ -225,8 +224,7 @@ constexpr auto d128_add_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
225224
{
226225
if (rhs_sig != 0U && (lhs_sign != rhs_sign))
227226
{
228-
const auto removed_zeros {detail::remove_trailing_zeros(lhs_sig)};
229-
if (removed_zeros.trimmed_number == 1U)
227+
if (is_power_of_ten(lhs_sig))
230228
{
231229
--lhs_sig;
232230
lhs_sig *= 10U;
@@ -245,8 +243,7 @@ constexpr auto d128_add_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
245243
{
246244
if (lhs_sig != 0U && (lhs_sign != rhs_sign))
247245
{
248-
const auto removed_zeros {detail::remove_trailing_zeros(rhs_sig)};
249-
if (removed_zeros.trimmed_number == 1U)
246+
if (is_power_of_ten(rhs_sig))
250247
{
251248
--rhs_sig;
252249
rhs_sig *= 10U;

0 commit comments

Comments
 (0)