lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] valyuta/002 90773f3 47/65: currency() rather than cu


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/002 90773f3 47/65: currency() rather than currency(0.0)
Date: Wed, 16 Sep 2020 16:55:20 -0400 (EDT)

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

    currency() rather than currency(0.0)
    
    default ctor is faster
---
 accountvalue.cpp  | 12 +++++-----
 currency_test.cpp |  2 +-
 gpt_specamt.cpp   |  2 +-
 group_values.cpp  |  2 +-
 ihs_acctval.cpp   | 26 ++++++++++-----------
 ihs_avmly.cpp     | 68 +++++++++++++++++++++++++++----------------------------
 ihs_avsolve.cpp   |  4 ++--
 ihs_avstrtgy.cpp  |  2 +-
 ihs_basicval.cpp  |  2 +-
 9 files changed, 60 insertions(+), 60 deletions(-)

diff --git a/accountvalue.cpp b/accountvalue.cpp
index c6210ed..21c475e 100644
--- a/accountvalue.cpp
+++ b/accountvalue.cpp
@@ -184,7 +184,7 @@ currency AccountValue::RunAllApplicableBases()
         ,mce_sep_full
         );
 
-    currency z = currency(0.0);
+    currency z {};
     if(Solving)
         {
         z = Solve();
@@ -331,8 +331,8 @@ void AccountValue::DoYear
 
     YearsCorridorFactor = BasicValues::GetCorridorFactor()[Year];
 
-    GrossPmts  .assign(12, currency(0.0));
-    NetPmts    .assign(12, currency(0.0));
+    GrossPmts  .assign(12, currency());
+    NetPmts    .assign(12, currency());
 
     // IHS !! Strategy here?
 
@@ -441,7 +441,7 @@ inline int AccountValue::MonthsToNextModalPmtDate() const
 // Set specamt according to selected strategy, in every year.
 void AccountValue::PerformSpecAmtStrategy()
 {
-    currency SA = currency(0.0);
+    currency SA {};
     switch(yare_input_.SpecifiedAmountStrategy[0])
         {
         case mce_sa_input_scalar:
@@ -766,7 +766,7 @@ void AccountValue::TxSetDeathBft()
             // Option 2: specamt plus AV, or corridor times AV if greater.
             // Negative AV doesn't decrease death benefit.
             deathbft = std::max
-                (ActualSpecAmt + std::max(currency(0.0), AV)
+                (ActualSpecAmt + std::max(currency(), AV)
                 ,corr
                 );
             break;
@@ -1066,7 +1066,7 @@ double AccountValue::GetProjectedCoiChargeInforce() const
 double AccountValue::GetSepAcctAssetsInforce() const
     {return 0.0;}
 currency AccountValue::IncrementBOM(int, int, double)
-    {return currency(0.0);}
+    {return currency();}
 void   AccountValue::IncrementEOM(int, int, currency, currency)
     {return;}
 void   AccountValue::IncrementEOY(int)
diff --git a/currency_test.cpp b/currency_test.cpp
index 068c4e4..a39f2ec 100644
--- a/currency_test.cpp
+++ b/currency_test.cpp
@@ -58,7 +58,7 @@ void currency_test::test_something()
     BOOST_TEST(6.50 == a1.d());
     BOOST_TEST( 650 == a1.m_);
 
-    currency a2 = currency(0.0) - a1;
+    currency a2 = currency() - a1;
     BOOST_TEST(-6.50 == a2.d());
     BOOST_TEST( -650 == a2.m_);
 
diff --git a/gpt_specamt.cpp b/gpt_specamt.cpp
index 434a8c0..ee4417b 100644
--- a/gpt_specamt.cpp
+++ b/gpt_specamt.cpp
@@ -92,7 +92,7 @@ class FindSpecAmt
         ,Premium         {a_Premium}
         ,NetPmtFactorTgt {a_NetPmtFactorTgt}
         ,NetPmtFactorExc {a_NetPmtFactorExc}
-        ,SpecAmt         {currency(0.0)}
+        ,SpecAmt         {currency {}}
         {
         }
     double operator()(double a_Trial)
diff --git a/group_values.cpp b/group_values.cpp
index 81987cb..6e8fbd4 100644
--- a/group_values.cpp
+++ b/group_values.cpp
@@ -419,7 +419,7 @@ census_run_result run_census_in_parallel::operator()
                     ;
             for(int month = inforce_month; month < 12; ++month)
                 {
-                currency assets = currency(0.0);
+                currency assets {};
 
                 // Get total case assets prior to interest crediting because
                 // those assets may determine the M&E charge.
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 0db06a3..42572d4 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -398,7 +398,7 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
     // TODO ?? TAXATION !! Shouldn't we increase initial SA if contract in 
corridor at issue?
     OldDB = OldSA;
 
-    SurrChg_.assign(BasicValues::GetLength(), currency(0.0));
+    SurrChg_.assign(BasicValues::GetLength(), currency());
 
     // TAXATION !! Input::InforceAnnualTargetPremium should be used here.
     double annual_target_premium = GetModalTgtPrem
@@ -575,15 +575,15 @@ void AccountValue::SetInitialValues()
 
     CumPmts                     = InforceCumPmts;
     TaxBasis                    = InforceTaxBasis;
-    YearlyTaxBasis.assign(BasicValues::GetLength(), currency(0.0));
+    YearlyTaxBasis.assign(BasicValues::GetLength(), currency());
     MlyNoLapsePrem              = 0.0;
     CumNoLapsePrem              = InforceCumNoLapsePrem;
 
     // Initialize all elements of this vector to 'false'. Then, when
     // the no-lapse criteria fail to be met, future values are right.
     YearlyNoLapseActive.assign(BasicValues::GetLength(), false);
-    loan_ullage_       .assign(BasicValues::GetLength(), currency(0.0));
-    withdrawal_ullage_ .assign(BasicValues::GetLength(), currency(0.0));
+    loan_ullage_       .assign(BasicValues::GetLength(), currency());
+    withdrawal_ullage_ .assign(BasicValues::GetLength(), currency());
     NoLapseActive               = true;
     if(NoLapseDboLvlOnly && mce_option1 != DeathBfts_->dbopt()[0])
         {
@@ -687,7 +687,7 @@ currency AccountValue::IncrementBOM
         {
         // Return value is total assets. After the policy has lapsed or
         // matured, there are no assets.
-        return currency(0.0);
+        return currency();
         }
 
     // Paranoid check.
@@ -759,8 +759,8 @@ void AccountValue::IncrementEOM
 
     // Save arguments, constraining their values to be nonnegative,
     // for calculating banded and tiered quantities.
-    AssetsPostBom  = std::max(currency(0.0), assets_post_bom  );
-    CumPmtsPostBom = std::max(currency(0.0), cum_pmts_post_bom);
+    AssetsPostBom  = std::max(currency(), assets_post_bom  );
+    CumPmtsPostBom = std::max(currency(), cum_pmts_post_bom);
 
     DoMonthCR();
 }
@@ -842,10 +842,10 @@ void AccountValue::InitializeYear()
     // value depends on the maximum loan, so it cannot be known here.
     ActualLoan                  = 0.0;
 
-    GrossPmts   .assign(12, currency(0.0));
-    EeGrossPmts .assign(12, currency(0.0));
-    ErGrossPmts .assign(12, currency(0.0));
-    NetPmts     .assign(12, currency(0.0));
+    GrossPmts   .assign(12, currency());
+    EeGrossPmts .assign(12, currency());
+    ErGrossPmts .assign(12, currency());
+    NetPmts     .assign(12, currency());
 
     InitializeSpecAmt();
 }
@@ -1020,7 +1020,7 @@ currency AccountValue::CSVBoost() const
         + yare_input_.CashValueEnhancementRate[Year]
         ;
     LMI_ASSERT(0.0 <= z);
-    return round_minutiae().c(z * std::max(currency(0.0), 
TotalAccountValue()));
+    return round_minutiae().c(z * std::max(currency(), TotalAccountValue()));
 }
 
 //============================================================================
@@ -1177,7 +1177,7 @@ void AccountValue::FinalizeYear()
 
     if(!Solving)
         {
-        csv_net = std::max(csv_net, currency(0.0));
+        csv_net = std::max(csv_net, currency());
         }
 
     if(Solving)
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index 58aecdf..9ac13e5 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -196,7 +196,7 @@ void AccountValue::DoMonthDR()
             );
         }
 
-    currency gross_1035 = currency(0.0);
+    currency gross_1035 {};
     if(0 == Year && 0 == Month)
         {
         gross_1035 = External1035Amount + Internal1035Amount;
@@ -292,7 +292,7 @@ void AccountValue::process_payment(currency payment)
     LMI_ASSERT(0.0 <= EeGrossPmts[Month]);
     LMI_ASSERT(0.0 <= ErGrossPmts[Month]);
 
-    currency gross_1035 = currency(0.0);
+    currency gross_1035 {};
     if(0 == Year && 0 == Month)
         {
         gross_1035 = External1035Amount + Internal1035Amount;
@@ -576,7 +576,7 @@ void AccountValue::TxExch1035()
 
     // TODO ?? Assume for now that all 1035 exchanges represent ee payments.
     EeGrossPmts[Month] = GrossPmts[Month];
-    currency amount_exempt_from_premium_tax = currency(0.0);
+    currency amount_exempt_from_premium_tax {};
     if(WaivePmTxInt1035)
         {
         amount_exempt_from_premium_tax = Internal1035Amount;
@@ -608,7 +608,7 @@ void AccountValue::TxExch1035()
 
     if(HoneymoonActive)
         {
-        HoneymoonValue += std::max(currency(0.0), GrossPmts[Month]);
+        HoneymoonValue += std::max(currency(), GrossPmts[Month]);
         }
 
     CumPmts += GrossPmts[Month];
@@ -820,7 +820,7 @@ void AccountValue::ChangeSupplAmtBy(currency delta)
 
     TermSpecAmt = std::max
         (TermSpecAmt
-        ,currency(0.0) // No minimum other than zero is defined.
+        ,currency() // No minimum other than zero is defined.
         );
     TermSpecAmt = round_specamt().c(TermSpecAmt); // already rounded?
     // At least for now, there is no effect on surrender charges.
@@ -911,11 +911,11 @@ void AccountValue::TxOptionChange()
                 {
                 if(mce_option2 == old_option)
                     {
-                    ChangeSpecAmtBy(std::max(currency(0.0), 
TotalAccountValue()));
+                    ChangeSpecAmtBy(std::max(currency(), TotalAccountValue()));
                     }
                 else if(mce_rop == old_option)
                     {
-                    ChangeSpecAmtBy(std::max(currency(0.0), CumPmts));
+                    ChangeSpecAmtBy(std::max(currency(), CumPmts));
                     }
                 else if(mce_mdb == old_option)
                     {
@@ -942,7 +942,7 @@ void AccountValue::TxOptionChange()
         case mce_option2:
             if(OptChgCanDecrSA)
                 {
-                ChangeSpecAmtBy(currency(-std::max(currency(0.0), 
TotalAccountValue())));
+                ChangeSpecAmtBy(currency(-std::max(currency(), 
TotalAccountValue())));
                 }
             else
                 {
@@ -952,7 +952,7 @@ void AccountValue::TxOptionChange()
         case mce_rop:
             if(OptChgCanDecrSA)
                 {
-                ChangeSpecAmtBy(currency(-std::max(currency(0.0), CumPmts)));
+                ChangeSpecAmtBy(currency(-std::max(currency(), CumPmts)));
                 }
             else
                 {
@@ -986,7 +986,7 @@ void AccountValue::TxSpecAmtChange()
 // > post-1035 exchange calculation of the seven pay will have a death benefit
 // > amount to base its calculations on.
 #if 1
-        ChangeSpecAmtBy(currency(0.0));
+        ChangeSpecAmtBy(currency());
 #else // 0
         // TODO ?? Changing specamt by zero is absurd. The following
         // commented-out alternative seems to do the same thing as
@@ -1226,7 +1226,7 @@ void AccountValue::TxAscertainDesiredPayment()
             ;
     LMI_ASSERT(materially_equal(GrossPmts[Month], EeGrossPmts[Month] + 
ErGrossPmts[Month]));
 
-    currency eepmt = currency(0.0);
+    currency eepmt {};
     if(ee_pay_this_month)
         {
         eepmt = PerformEePmtStrategy();
@@ -1241,7 +1241,7 @@ void AccountValue::TxAscertainDesiredPayment()
         GrossPmts  [Month] += eepmt;
         }
 
-    currency erpmt = currency(0.0);
+    currency erpmt {};
     if(er_pay_this_month)
         {
         erpmt = PerformErPmtStrategy();
@@ -1326,7 +1326,7 @@ void AccountValue::TxLimitPayment(double a_maxpmt)
 
     if(mce_reduce_prem == yare_input_.AvoidMecMethod && 
!Irc7702A_->IsMecAlready())
         {
-        currency gross_1035 = currency(0.0);
+        currency gross_1035 {};
         if(0 == Year && 0 == Month)
             {
             gross_1035 = External1035Amount + Internal1035Amount;
@@ -1430,7 +1430,7 @@ void AccountValue::TxAcceptPayment(currency a_pmt)
     LMI_ASSERT(0.0 <= a_pmt);
     // Internal 1035 exchanges may be exempt from premium tax; they're
     // handled elsewhere, so here the exempt amount is always zero.
-    currency actual_load = GetPremLoad(a_pmt, currency(0.0));
+    currency actual_load = GetPremLoad(a_pmt, currency());
     currency net_pmt = a_pmt - actual_load;
     LMI_ASSERT(0.0 <= net_pmt);
     NetPmts[Month] += net_pmt;
@@ -1443,12 +1443,12 @@ void AccountValue::TxAcceptPayment(currency a_pmt)
 
     process_payment(net_pmt);
 
-    Dcv += std::max(currency(0.0), net_pmt);
+    Dcv += std::max(currency(), net_pmt);
     LMI_ASSERT(0.0 <= Dcv);
 
     if(HoneymoonActive)
         {
-        HoneymoonValue += std::max(currency(0.0), a_pmt);
+        HoneymoonValue += std::max(currency(), a_pmt);
         }
 
     CumPmts += a_pmt;
@@ -1687,7 +1687,7 @@ void AccountValue::TxSetDeathBft()
         case mce_option2:
             {
             // Negative AV doesn't decrease death benefit.
-            DBIgnoringCorr = ActualSpecAmt + std::max(currency(0.0), 
TotalAccountValue());
+            DBIgnoringCorr = ActualSpecAmt + std::max(currency(), 
TotalAccountValue());
             DB7702A        = ActualSpecAmt;
             }
             break;
@@ -1696,8 +1696,8 @@ void AccountValue::TxSetDeathBft()
             // SA + sum of premiums less withdrawals, but not < SA;
             // i.e., ignore 'CumPmts' if it is less than zero, as it
             // easily can be, e.g., if WDs are not limited to basis.
-            DBIgnoringCorr = ActualSpecAmt + std::max(currency(0.0), CumPmts);
-            DB7702A        = ActualSpecAmt + std::max(currency(0.0), CumPmts);
+            DBIgnoringCorr = ActualSpecAmt + std::max(currency(), CumPmts);
+            DB7702A        = ActualSpecAmt + std::max(currency(), CumPmts);
             }
             break;
         case mce_mdb:
@@ -1716,7 +1716,7 @@ void AccountValue::TxSetDeathBft()
     // surrender charge must be subtracted, increasing the account value.
     currency cash_value_for_corridor =
           TotalAccountValue()
-        - std::min(currency(0.0), SurrChg())
+        - std::min(currency(), SurrChg())
         + GetRefundableSalesLoad()
 //        + std::max(0.0, ExpRatReserve) // This would be added if it existed.
         ;
@@ -1728,7 +1728,7 @@ void AccountValue::TxSetDeathBft()
 
     DBReflectingCorr = std::max
         (DBIgnoringCorr
-        ,round_death_benefit().c(YearsCorridorFactor * std::max(currency(0.0), 
cash_value_for_corridor))
+        ,round_death_benefit().c(YearsCorridorFactor * std::max(currency(), 
cash_value_for_corridor))
         );
     DBReflectingCorr = round_death_benefit().c(DBReflectingCorr); // already 
rounded?
     LMI_ASSERT(0.0 <= DBReflectingCorr);
@@ -1742,7 +1742,7 @@ void AccountValue::TxSetDeathBft()
         ,   (
                 YearsCorridorFactor
             *   (   Dcv
-                -   std::min(currency(0.0), SurrChg())
+                -   std::min(currency(), SurrChg())
                 +   GetRefundableSalesLoad()
 //                +   std::max(0.0, ExpRatReserve) // This would be added if 
it existed.
                 )
@@ -1777,7 +1777,7 @@ void AccountValue::TxSetTermAmt()
         return;
         }
 
-    TermDB = std::max(currency(0.0), TermSpecAmt + DBIgnoringCorr - 
DBReflectingCorr);
+    TermDB = std::max(currency(), TermSpecAmt + DBIgnoringCorr - 
DBReflectingCorr);
     TermDB = round_death_benefit().c(TermDB); // already rounded?
 }
 
@@ -2390,13 +2390,13 @@ void AccountValue::SetMaxWD()
         + (AVRegLn  + AVPrfLn)
         - (RegLnBal + PrfLnBal)
         - anticipated_deduction(MaxWDDed_)
-        - std::max(currency(0.0), SurrChg())
+        - std::max(currency(), SurrChg())
         ;
     if(MaxWD < MinWD)
         {
-        MaxWD = currency(0.0);
+        MaxWD = currency();
         }
-    MaxWD = std::max(currency(0.0), MaxWD);
+    MaxWD = std::max(currency(), MaxWD);
 }
 
 /// Take a withdrawal.
@@ -2436,7 +2436,7 @@ void AccountValue::TxTakeWD()
 
     if(Solving)
         {
-        withdrawal_ullage_[Year] = std::max(currency(0.0), RequestedWD - 
MaxWD);
+        withdrawal_ullage_[Year] = std::max(currency(), RequestedWD - MaxWD);
         }
 
     if(Solving || mce_run_gen_curr_sep_full == RunBasis_)
@@ -2610,7 +2610,7 @@ void AccountValue::TxTakeWD()
             // Do you really want 'face' here rather than specamt? --Yes
             if(WdDecrSpecAmtDboLvl)
                 {
-                ChangeSpecAmtBy(currency(0.0) - GrossWD);
+                ChangeSpecAmtBy(currency() - GrossWD);
                 // Min AV after WD not directly implemented.
                 // If WD causes AV < min AV, do we:
                 //   reduce the WD?
@@ -2630,7 +2630,7 @@ void AccountValue::TxTakeWD()
             {
             if(WdDecrSpecAmtDboInc)
                 {
-                ChangeSpecAmtBy(currency(0.0) - GrossWD);
+                ChangeSpecAmtBy(currency() - GrossWD);
                 }
             else
                 {
@@ -2642,7 +2642,7 @@ void AccountValue::TxTakeWD()
             {
             if(WdDecrSpecAmtDboRop)
                 {
-                ChangeSpecAmtBy(currency(0.0) - GrossWD);
+                ChangeSpecAmtBy(currency() - GrossWD);
                 }
             else
                 {
@@ -2692,7 +2692,7 @@ void AccountValue::SetMaxLoan()
           (AVGenAcct + AVSepAcct) * MaxLoanAVMult
         + (AVRegLn + AVPrfLn)
         - anticipated_deduction(MaxLoanDed_)
-        - std::max(currency(0.0), SurrChg())
+        - std::max(currency(), SurrChg())
         ;
 
     // Illustrations generally permit loans only on anniversary.
@@ -2778,12 +2778,12 @@ void AccountValue::TxTakeLoan()
     if(Solving)
         {
         ActualLoan = RequestedLoan;
-        loan_ullage_[Year] = std::max(currency(0.0), RequestedLoan - 
max_loan_increment);
+        loan_ullage_[Year] = std::max(currency(), RequestedLoan - 
max_loan_increment);
         }
     else
         {
         ActualLoan = std::min(max_loan_increment, RequestedLoan);
-        ActualLoan = std::max(ActualLoan, currency(0.0));
+        ActualLoan = std::max(ActualLoan, currency());
         // TODO ?? Shouldn't this happen in FinalizeMonth()?
         InvariantValues().NewCashLoan[Year] = ActualLoan;
         }
@@ -2863,7 +2863,7 @@ void AccountValue::TxTestLapse()
         ;
     if(!LapseIgnoresSurrChg)
         {
-        lapse_test_csv -= std::max(currency(0.0), SurrChg());
+        lapse_test_csv -= std::max(currency(), SurrChg());
         }
     lapse_test_csv = std::max(lapse_test_csv, HoneymoonValue);
 
diff --git a/ihs_avsolve.cpp b/ihs_avsolve.cpp
index b0ce5b4..d6427ae 100644
--- a/ihs_avsolve.cpp
+++ b/ihs_avsolve.cpp
@@ -282,7 +282,7 @@ currency AccountValue::SolveGuarPremium()
     // Store original er premiums for later restoration.
     std::vector<currency> stored = Outlay_->er_modal_premiums();
     // Zero out er premiums and solve for ee premiums only.
-    Outlay_->set_er_modal_premiums(currency(0.0), 0, BasicValues::GetLength());
+    Outlay_->set_er_modal_premiums(currency(), 0, BasicValues::GetLength());
 
     bool temp_solving     = Solving;
     Solving               = true;
@@ -294,7 +294,7 @@ currency AccountValue::SolveGuarPremium()
         ,0
         ,BasicValues::GetLength()
         ,mce_solve_for_endt
-        ,currency(0.0)
+        ,currency()
         ,BasicValues::GetLength()
         ,mce_gen_guar
         ,mce_sep_full
diff --git a/ihs_avstrtgy.cpp b/ihs_avstrtgy.cpp
index dc2dbf8..27eb18a 100644
--- a/ihs_avstrtgy.cpp
+++ b/ihs_avstrtgy.cpp
@@ -175,7 +175,7 @@ void AccountValue::PerformSupplAmtStrategy()
 {
     for(int j = 0; j < BasicValues::Length; ++j)
         {
-        currency m = currency(0.0); // No minimum other than zero is defined.
+        currency m {}; // No minimum other than zero is defined.
         currency explicit_value = DeathBfts_->supplamt()[j];
         mcenum_sa_strategy strategy = 
yare_input_.SupplementalAmountStrategy[j];
         currency z = CalculateSpecAmtFromStrategy(j, 0, explicit_value, 
strategy);
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index 3457c66..07c1d97 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -1605,7 +1605,7 @@ currency BasicValues::GetModalSpecAmtMlyDed(currency, 
mcenum_mode) const
         << "No maximum specified amount is defined for this product."
         << LMI_FLUSH
         ;
-    return currency(0.0);
+    return currency {};
 }
 
 /// 'Unusual' banding is one particular approach we needed to model.



reply via email to

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