@@ -888,27 +888,10 @@ constexpr auto operator+(decimal64_fast lhs, decimal64_fast rhs) noexcept -> dec
888888 }
889889 #endif
890890
891- bool lhs_bigger {lhs > rhs};
892- if (lhs.isneg () && rhs.isneg ())
893- {
894- lhs_bigger = !lhs_bigger;
895- }
896-
897- // Ensure that lhs is always the larger for ease of impl
898- if (!lhs_bigger)
899- {
900- detail::swap (lhs, rhs);
901- }
902-
903- if (!lhs.isneg () && rhs.isneg ())
904- {
905- return lhs - abs (rhs);
906- }
907-
908891 return detail::d64_add_impl<decimal64_fast>(
909- lhs.significand_ , lhs.biased_exponent (), lhs.sign_ ,
910- rhs.significand_ , rhs.biased_exponent (), rhs.sign_
911- );
892+ lhs.significand_ , lhs.biased_exponent (), lhs.sign_ ,
893+ rhs.significand_ , rhs.biased_exponent (), rhs.sign_ ,
894+ ( abs (lhs) > abs (rhs)) );
912895}
913896
914897template <typename Integer>
@@ -925,45 +908,16 @@ constexpr auto operator+(decimal64_fast lhs, Integer rhs) noexcept
925908 }
926909 #endif
927910
928- bool lhs_bigger {lhs > rhs};
929- if (lhs.isneg () && (rhs < 0 ))
930- {
931- lhs_bigger = !lhs_bigger;
932- }
933911 auto sig_rhs {static_cast <promoted_significand_type>(detail::make_positive_unsigned (rhs))};
934- bool abs_lhs_bigger {abs (lhs) > sig_rhs};
935-
936- auto lhs_components {detail::decimal64_fast_components{lhs.significand_ , lhs.biased_exponent (), lhs.isneg ()}};
912+ const bool abs_lhs_bigger {abs (lhs) > sig_rhs};
937913
938914 exp_type exp_rhs {0 };
939915 detail::normalize<decimal64>(sig_rhs, exp_rhs);
940- auto unsigned_sig_rhs {static_cast <detail::decimal64_fast_components::significand_type>(sig_rhs)};
941- auto rhs_components {detail::decimal64_fast_components{unsigned_sig_rhs, exp_rhs, (rhs < 0 )}};
942-
943- if (!lhs_bigger)
944- {
945- detail::swap (lhs_components, rhs_components);
946- abs_lhs_bigger = !abs_lhs_bigger;
947- }
948-
949- #ifdef BOOST_DECIMAL_DEBUG_ADD
950- std::cerr << " Lhs sig: " << lhs_components.sig
951- << " \n Lhs exp: " << lhs_components.exp
952- << " \n Rhs sig: " << rhs_components.sig
953- << " \n Rhs exp: " << rhs_components.exp << std::endl;
954- #endif
916+ const auto final_sig_rhs {static_cast <decimal64_fast::significand_type>(sig_rhs)};
955917
956- if (!lhs_components.sign && rhs_components.sign )
957- {
958- return detail::d64_sub_impl<decimal64_fast>(lhs_components.sig , lhs_components.exp , lhs_components.sign ,
959- rhs_components.sig , rhs_components.exp , rhs_components.sign ,
960- abs_lhs_bigger);
961- }
962- else
963- {
964- return detail::d64_add_impl<decimal64_fast>(lhs_components.sig , lhs_components.exp , lhs_components.sign ,
965- rhs_components.sig , rhs_components.exp , rhs_components.sign );
966- }
918+ return detail::d64_add_impl<decimal64_fast>(lhs.significand_ , lhs.biased_exponent (), lhs.sign_ ,
919+ final_sig_rhs, exp_rhs, (rhs < 0 ),
920+ abs_lhs_bigger);
967921}
968922
969923template <typename Integer>
0 commit comments