@@ -254,83 +254,6 @@ constexpr auto d64_add_impl(T lhs_sig, U lhs_exp, bool lhs_sign,
254254 return {res_sig, new_exp, new_sign};
255255}
256256
257- template <typename ReturnType, BOOST_DECIMAL_INTEGRAL T, BOOST_DECIMAL_INTEGRAL U>
258- constexpr auto d64_add_impl (T lhs_sig, U lhs_exp, bool lhs_sign,
259- T rhs_sig, U rhs_exp, bool rhs_sign) noexcept -> ReturnType
260- {
261- const bool sign {lhs_sign};
262-
263- auto delta_exp {lhs_exp > rhs_exp ? lhs_exp - rhs_exp : rhs_exp - lhs_exp};
264-
265- if (delta_exp > detail::precision_v<decimal64> + 1 )
266- {
267- // If the difference in exponents is more than the digits of accuracy
268- // we return the larger of the two
269- //
270- // e.g. 1e20 + 1e-20 = 1e20
271-
272- return {lhs_sig, lhs_exp, lhs_sign};
273- }
274- else if (delta_exp == detail::precision_v<decimal64> + 1 )
275- {
276- // Only need to see if we need to add one to the
277- // significand of the bigger value
278- //
279- // e.g. 1.234567e5 + 9.876543e-2 = 1.234568e5
280-
281- if (rhs_sig >= UINT64_C (5'000'000'000'000'000 ))
282- {
283- ++lhs_sig;
284- return {lhs_sig, lhs_exp, lhs_sign};
285- }
286- else
287- {
288- return {lhs_sig, lhs_exp, lhs_sign};
289- }
290- }
291-
292- // The two numbers can be added together without special handling
293- //
294- // If we can add to the lhs sig rather than dividing we can save some precision
295- // 64-bit sign int can have 19 digits, and our normalized significand has 16
296- if (delta_exp <= 3 )
297- {
298- lhs_sig *= pow10 (static_cast <T>(delta_exp));
299- lhs_exp -= delta_exp;
300- delta_exp = 0 ;
301- }
302- else
303- {
304- lhs_sig *= 1000 ;
305- delta_exp -= 3 ;
306- lhs_exp -= 3 ;
307-
308- if (delta_exp > 1 )
309- {
310- rhs_sig /= pow10 (static_cast <T>(delta_exp - 1 ));
311- delta_exp = 1 ;
312- }
313-
314- if (delta_exp == 1 )
315- {
316- detail::fenv_round<decimal64>(rhs_sig, rhs_sign);
317- }
318- }
319-
320- // Both of the significands are well under 64-bits, so we can fit them into int64_t without issue
321- const auto new_sig {static_cast <typename ReturnType::significand_type>(lhs_sig) +
322- static_cast <typename ReturnType::significand_type>(rhs_sig)};
323- const auto new_exp {lhs_exp};
324-
325- #ifdef BOOST_DECIMAL_DEBUG_ADD
326- std::cerr << " Res Sig: " << new_sig
327- << " \n Res Exp: " << new_exp
328- << " \n Res Neg: " << sign << std::endl;
329- #endif
330-
331- return {new_sig, new_exp, sign};
332- }
333-
334257#ifdef _MSC_VER
335258# pragma warning(push)
336259# pragma warning(disable: 4127) // If constexpr macro only works for C++17 and above
0 commit comments