lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 35eb8545 09/13: Prefer a calculation with les


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 35eb8545 09/13: Prefer a calculation with less roundoff error
Date: Mon, 9 May 2022 20:13:18 -0400 (EDT)

branch: master
commit 35eb8545fc4bfe700da5c7cf48440f45357726d8
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Prefer a calculation with less roundoff error
    
    Hoist a constant 'k', using
      k * (r0 + r1 + ... + rN)
    in preference to
      k * r0 + k * r1 + ... + k * rN
    when they're materially the same, because the former is less susceptible
    to roundoff, which differs between i686 and x86_64. Infrequently, one of
    the terms in the summation is
      ... + k' * rm + ...
    where "k'" differs from the usual 'k'; in that case, use the more
    complicated formula despite its greater roundoff error.
---
 ihs_avmly.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index d38b2648..d2005fd3 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -1565,7 +1565,13 @@ currency AccountValue::GetPremLoad
         ||  materially_equal(total_load, sum_of_separate_loads)
         );
 
-    return round_net_premium().c(sum_of_separate_loads);
+    // When they're materially equal, prefer 'total_load' because it's
+    // less susceptible to differences between i686 and x86_64.
+    return
+        PremiumTax_->is_tiered()
+        ? round_net_premium().c(sum_of_separate_loads)
+        : round_net_premium().c(total_load)
+        ;
 }
 
 //============================================================================



reply via email to

[Prev in Thread] Current Thread [Next in Thread]