[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
- [lmi-commits] [lmi] master updated (061fa21 -> 110f4b9), Greg Chicares, 2020/08/26
- [lmi-commits] [lmi] master a5279b7 5/7: Round gross and net withdrawals, Greg Chicares, 2020/08/26
- [lmi-commits] [lmi] master 110f4b9 7/7: Round apportioned AV increments, Greg Chicares, 2020/08/26
- [lmi-commits] [lmi] master 2b902eb 1/7: Refactor for clarity, Greg Chicares, 2020/08/26
- [lmi-commits] [lmi] master 3453e8d 2/7: Rename a local variable, Greg Chicares, 2020/08/26
- [lmi-commits] [lmi] master d618023 3/7: Preserve total specamt when apportioning changes,
Greg Chicares <=
- [lmi-commits] [lmi] master 53ebc6f 4/7: Round changes to specamt, Greg Chicares, 2020/08/26
- [lmi-commits] [lmi] master ceaa572 6/7: Round apportioned AV decrements, Greg Chicares, 2020/08/26