lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] valyuta/002 97eb31d 20/21: Use negation operator


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/002 97eb31d 20/21: Use negation operator
Date: Fri, 18 Sep 2020 21:53:50 -0400 (EDT)

branch: valyuta/002
commit 97eb31d26bafd1f127c3312756c58eea7bea23ea
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Use negation operator
---
 ihs_acctval.cpp |  2 +-
 ihs_avmly.cpp   | 25 +++++++++++++------------
 ihs_avsolve.cpp |  2 +-
 3 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 9e6f0b2..e8bc719 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -1317,7 +1317,7 @@ void AccountValue::FinalizeYear()
     VariantValues().NetPmt[Year] = std::accumulate
         (NetPmts.begin()
         ,NetPmts.end()
-        ,currency() - YearsTotalGptForceout // unary operator-()
+        ,-YearsTotalGptForceout
         ).d();
 
     if(mce_run_gen_curr_sep_full == RunBasis_)
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index 41e7a1e..96aba3a 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -187,7 +187,7 @@ void AccountValue::DoMonthDR()
         {
         Irc7702A_->UpdatePmt7702A
             (Dcv
-            ,-NetWD.d() // TAXATION !! This should be gross, not net. // unary 
operator-()
+            ,-NetWD.d() // TAXATION !! This should be gross, not net.
             ,false
             ,AnnualTargetPrem.d()
             ,YearsTotLoadTgtLowestPremtax
@@ -941,7 +941,7 @@ void AccountValue::TxOptionChange()
         case mce_option2:
             if(OptChgCanDecrSA)
                 {
-                ChangeSpecAmtBy(currency() - std::max(currency(), 
TotalAccountValue())); // unary operator-()
+                ChangeSpecAmtBy(-std::max(currency(), TotalAccountValue()));
                 }
             else
                 {
@@ -951,7 +951,7 @@ void AccountValue::TxOptionChange()
         case mce_rop:
             if(OptChgCanDecrSA)
                 {
-                ChangeSpecAmtBy(currency() - std::max(currency(), CumPmts)); 
// unary operator-()
+                ChangeSpecAmtBy(-std::max(currency(), CumPmts));
                 }
             else
                 {
@@ -961,7 +961,7 @@ void AccountValue::TxOptionChange()
         case mce_mdb:
             {
             // Change spec amt by its additive inverse, making it 0.
-            ChangeSpecAmtBy(currency() - (ActualSpecAmt + TermSpecAmt)); // 
unary operator-()
+            ChangeSpecAmtBy(-(ActualSpecAmt + TermSpecAmt));
             }
             break;
         }
@@ -1583,13 +1583,14 @@ void AccountValue::TxLoanRepay()
         return;
         }
 
-    // TODO ?? This idiom seems too cute. And it can return -0.0 .
+    // TODO ?? This idiom seems too cute. And it can return -0.0 . See:
+    //   https://lists.nongnu.org/archive/html/lmi/2020-09/msg00005.html
     // Maximum repayment is total debt.
-    ActualLoan = currency() - std::min(currency() - RequestedLoan, RegLnBal + 
PrfLnBal); // unary operator-()
+    ActualLoan = -std::min(-RequestedLoan, RegLnBal + PrfLnBal);
 
     process_distribution(ActualLoan);
-    LMI_ASSERT(currency() == progressively_reduce(AVRegLn , AVPrfLn , 
currency() - ActualLoan)); // unary operator-()
-    LMI_ASSERT(currency() == progressively_reduce(RegLnBal, PrfLnBal, 
currency() - ActualLoan)); // unary operator-()
+    LMI_ASSERT(currency() == progressively_reduce(AVRegLn , AVPrfLn , 
-ActualLoan));
+    LMI_ASSERT(currency() == progressively_reduce(RegLnBal, PrfLnBal, 
-ActualLoan));
 
 // This seems wrong. If we're changing something that's invariant among
 // bases, why do we change it for each basis?
@@ -2607,7 +2608,7 @@ void AccountValue::TxTakeWD()
             // Do you really want 'face' here rather than specamt? --Yes
             if(WdDecrSpecAmtDboLvl)
                 {
-                ChangeSpecAmtBy(currency() - GrossWD); // unary operator-()
+                ChangeSpecAmtBy(-GrossWD);
                 // Min AV after WD not directly implemented.
                 // If WD causes AV < min AV, do we:
                 //   reduce the WD?
@@ -2627,7 +2628,7 @@ void AccountValue::TxTakeWD()
             {
             if(WdDecrSpecAmtDboInc)
                 {
-                ChangeSpecAmtBy(currency() - GrossWD); // unary operator-()
+                ChangeSpecAmtBy(-GrossWD);
                 }
             else
                 {
@@ -2639,7 +2640,7 @@ void AccountValue::TxTakeWD()
             {
             if(WdDecrSpecAmtDboRop)
                 {
-                ChangeSpecAmtBy(currency() - GrossWD); // unary operator-()
+                ChangeSpecAmtBy(-GrossWD);
                 }
             else
                 {
@@ -2670,7 +2671,7 @@ void AccountValue::TxTakeWD()
             {
             // TODO ?? TAXATION !! What if reference argument
             // 'premiums_paid_increment' is modified?
-            double premiums_paid_increment = 0.0 - GrossWD.d(); // unary 
operator-()
+            double premiums_paid_increment = 0.0 - GrossWD.d();
             Irc7702_->ProcessGptPmt(Year, premiums_paid_increment);
             }
         }
diff --git a/ihs_avsolve.cpp b/ihs_avsolve.cpp
index f95cd71..30c454d 100644
--- a/ihs_avsolve.cpp
+++ b/ihs_avsolve.cpp
@@ -208,7 +208,7 @@ currency AccountValue::SolveTest(currency a_CandidateValue)
         );
     currency worst_negative = std::min
         (most_negative_csv
-        ,currency() - greatest_ullage // really want a unary-negation operator
+        ,-greatest_ullage
         );
 
     // SolveTargetDuration_ is in origin one. That's natural for loop



reply via email to

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