lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master d618023 3/7: Preserve total specamt when appo


From: Greg Chicares
Subject: [lmi-commits] [lmi] master d618023 3/7: Preserve total specamt when apportioning changes
Date: Wed, 26 Aug 2020 20:09:02 -0400 (EDT)

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

    Preserve total specamt when apportioning changes
    
    The crucial invariant is
      new {base + term} =  Δ + old {base + term}
    which is not guaranteed by
      θ = (old term) / (old base + old term)
      base = round(base * (1 - θ))
      term = round(term * θ)
    Cf. commit 061fa216bf330 of 20200825T2228Z, which gives the example that
    round(5.0) may not equal (round(2.5) + round(2.5)).
---
 ihs_avmly.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index e3136c4..b7d24e6 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -715,7 +715,9 @@ void AccountValue::ChangeSpecAmtBy(double delta)
             }
 
         ActualSpecAmt += delta * (1.0 - term_proportion);
-        TermSpecAmt += delta * term_proportion;
+        ActualSpecAmt = round_specamt()(ActualSpecAmt);
+        TermSpecAmt = old_total_specamt + delta - ActualSpecAmt;
+
         if(TermSpecAmt < 0.0)
             {
             // Reducing the term rider's specified amount to a value



reply via email to

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