@@ -777,26 +777,10 @@ constexpr auto operator+(decimal128_fast lhs, decimal128_fast rhs) noexcept -> d
777777 }
778778 #endif
779779
780- bool lhs_bigger {lhs > rhs};
781- if (lhs.isneg () && rhs.isneg ())
782- {
783- lhs_bigger = !lhs_bigger;
784- }
785-
786- // Ensure that lhs is always the larger for ease of impl
787- if (!lhs_bigger)
788- {
789- detail::swap (lhs, rhs);
790- }
791-
792- if (!lhs.isneg () && rhs.isneg ())
793- {
794- return lhs - abs (rhs);
795- }
796-
797780 return detail::d128_add_impl<decimal128_fast>(
798781 lhs.significand_ , lhs.biased_exponent (), lhs.sign_ ,
799- rhs.significand_ , rhs.biased_exponent (), rhs.sign_ );
782+ rhs.significand_ , rhs.biased_exponent (), rhs.sign_ ,
783+ (abs (lhs) > abs (rhs)));
800784};
801785
802786template <typename Integer>
@@ -812,47 +796,15 @@ constexpr auto operator+(decimal128_fast lhs, Integer rhs) noexcept
812796 }
813797 #endif
814798
815- bool lhs_bigger {lhs > rhs};
816- if (lhs.isneg () && (rhs < 0 ))
817- {
818- lhs_bigger = !lhs_bigger;
819- }
820-
821799 auto sig_rhs {static_cast <detail::uint128>(detail::make_positive_unsigned (rhs))};
822800 bool abs_lhs_bigger {abs (lhs) > sig_rhs};
823801
824- auto lhs_components {detail::decimal128_fast_components{lhs.significand_ , lhs.biased_exponent (), lhs.isneg ()}};
825-
826802 exp_type exp_rhs {0 };
827803 detail::normalize<decimal128>(sig_rhs, exp_rhs);
828- auto rhs_components {detail::decimal128_fast_components{sig_rhs, exp_rhs, (rhs < 0 )}};
829804
830- if (!lhs_bigger)
831- {
832- detail::swap (lhs_components, rhs_components);
833- abs_lhs_bigger = !abs_lhs_bigger;
834- }
835-
836- #ifdef BOOST_DECIMAL_DEBUG_ADD
837- std::cerr << " Lhs sig: " << lhs_components.sig
838- << " \n Lhs exp: " << lhs_components.exp
839- << " \n Rhs sig: " << rhs_components.sig
840- << " \n Rhs exp: " << rhs_components.exp << std::endl;
841- #endif
842-
843- if (!lhs_components.sign && rhs_components.sign )
844- {
845- return detail::d128_sub_impl<decimal128_fast>(
846- lhs_components.sig , lhs_components.exp , lhs_components.sign ,
847- rhs_components.sig , rhs_components.exp , rhs_components.sign ,
848- abs_lhs_bigger);
849- }
850- else
851- {
852- return detail::d128_add_impl<decimal128_fast>(
853- lhs_components.sig , lhs_components.exp , lhs_components.sign ,
854- rhs_components.sig , rhs_components.exp , rhs_components.sign );
855- }
805+ return detail::d128_add_impl<decimal128_fast>(lhs.significand_ , lhs.biased_exponent (), lhs.sign_ ,
806+ sig_rhs, exp_rhs, (rhs < 0 ),
807+ abs_lhs_bigger);
856808}
857809
858810template <typename Integer>
0 commit comments