lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 53ebc6f 4/7: Round changes to specamt


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 53ebc6f 4/7: Round changes to specamt
Date: Wed, 26 Aug 2020 20:09:02 -0400 (EDT)

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

    Round changes to specamt
    
    If specamt is required to be an integral number of dollars at all times,
    then what does it mean to increase it by $0.97 or decrease it by $.01?
    Formerly, lmi did this:
       1000 + 0.97 = 1000.97 // temporarily not whole dollars
       round(1000.97) // forced to whole dollars: maybe 1000, maybe 1001
    Now, the increment is rounded before it is applied:
       round(0.97) // maybe $1, maybe $0
    which gives a final result that's just as good, but not necessarily the
    same. The motivation is to perform only integer arithmetic on values
    that are constrained to be integers, which ultimately makes it easy to
    replace floating-point values with an integral currency type.
---
 ihs_avmly.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index b7d24e6..911ff3c 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -690,6 +690,7 @@ double AccountValue::minimum_specified_amount(bool 
issuing_now, bool term_rider)
 // Make sure ActualSpecAmt is never less than minimum specamt.
 void AccountValue::ChangeSpecAmtBy(double delta)
 {
+    delta = round_specamt()(delta);
     double term_proportion = 0.0;
     double const old_total_specamt = ActualSpecAmt + TermSpecAmt;
     // Adjust term here only if it's formally a rider.
@@ -783,6 +784,7 @@ void AccountValue::ChangeSpecAmtBy(double delta)
 
 void AccountValue::ChangeSupplAmtBy(double delta)
 {
+    delta = round_specamt()(delta);
     TermSpecAmt += delta;
 
     TermSpecAmt = std::max



reply via email to

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