lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] valyuta/005 df368ca 6/9: Replace currency::d() with


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/005 df368ca 6/9: Replace currency::d() with d(currency) almost everywhere
Date: Wed, 20 Jan 2021 00:51:32 -0500 (EST)

branch: valyuta/005
commit df368ca51bc8aace950480d4120f30fafedc61b4
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Replace currency::d() with d(currency) almost everywhere
    
    There's no present need to remove the old function in the implementation
    of class currency or of class round_to<>.
---
 accountvalue.cpp          |  34 ++++-----
 basicvalues.cpp           |   8 +-
 currency.hpp              |   4 +
 currency_test.cpp         |  10 ++-
 gpt_specamt.cpp           |   4 +-
 ihs_acctval.cpp           |  92 +++++++++++------------
 ihs_avdebug.cpp           |   2 +-
 ihs_avmly.cpp             | 182 +++++++++++++++++++++++-----------------------
 ihs_avsolve.cpp           |   6 +-
 ihs_basicval.cpp          |  30 ++++----
 ledger_invariant_init.cpp |   4 +-
 ledger_variant_init.cpp   |   2 +-
 round_to_test.cpp         |   2 +-
 solve.cpp                 |  12 +--
 14 files changed, 202 insertions(+), 190 deletions(-)

diff --git a/accountvalue.cpp b/accountvalue.cpp
index f5aad4b..5c775f1 100644
--- a/accountvalue.cpp
+++ b/accountvalue.cpp
@@ -338,16 +338,16 @@ void AccountValue::DoYear
             }
         }
 
-    VariantValues().AcctVal[Year] = (AVUnloaned + AVRegLn + AVPrfLn).d();
+    VariantValues().AcctVal[Year] = d(AVUnloaned + AVRegLn + AVPrfLn);
     VariantValues().CSVNet[Year] = VariantValues().AcctVal[Year] - 
VariantValues().SurrChg[Year];
     // Update death benefit: "deathbft" currently holds benefit as of the
     //   beginning of month 12, but we want it as of the end of that month,
     //   in case the corridor or option 2 drove it up during the last month.
     TxSetDeathBft();
-    VariantValues().EOYDeathBft[Year] = deathbft.d();
+    VariantValues().EOYDeathBft[Year] = d(deathbft);
 
     // IHS !! Change one of these names, which differ only in the terminal 's'.
-    InvariantValues().GrossPmt[Year] += std::accumulate(GrossPmts.begin(), 
GrossPmts.end(), C0).d();
+    InvariantValues().GrossPmt[Year] += d(std::accumulate(GrossPmts.begin(), 
GrossPmts.end(), C0));
     InvariantValues().Outlay[Year] =
             InvariantValues().GrossPmt   [Year]
         -   InvariantValues().NetWD      [Year]
@@ -490,7 +490,7 @@ void AccountValue::PerformSpecAmtStrategy()
 
     for(int j = 0; j < BasicValues::GetLength(); ++j)
         {
-        InvariantValues().SpecAmt[j] = SA.d();
+        InvariantValues().SpecAmt[j] = d(SA);
         }
 }
 
@@ -550,7 +550,7 @@ void AccountValue::TxOptionChange()
     // Carry the new spec amt forward into all future years.
     for(int j = Year; j < BasicValues::GetLength(); ++j)
         {
-        InvariantValues().SpecAmt[j] = ActualSpecAmt.d();
+        InvariantValues().SpecAmt[j] = d(ActualSpecAmt);
         }
 }
 
@@ -582,7 +582,7 @@ void AccountValue::TxSpecAmtChange()
     // Carry the new spec amt forward into all future years.
     for(int j = Year; j < BasicValues::GetLength(); ++j)
         {
-        InvariantValues().SpecAmt[j] = ActualSpecAmt.d();
+        InvariantValues().SpecAmt[j] = d(ActualSpecAmt);
         }
 }
 
@@ -727,7 +727,7 @@ void AccountValue::TxLoanRepay()
 
     AVUnloaned -= RequestedLoan;
     AVRegLn += RequestedLoan;    // IHS !! Preferred loans--see lmi.
-    InvariantValues().NewCashLoan[Year] = RequestedLoan.d();
+    InvariantValues().NewCashLoan[Year] = d(RequestedLoan);
 }
 
 /// Set account value before monthly deductions.
@@ -783,7 +783,7 @@ void AccountValue::TxSetCoiCharge()
     TxSetDeathBft();
 
     // Negative AV doesn't increase NAAR.
-    NAAR = deathbft * mlyguarv - (AVUnloaned + AVRegLn + AVPrfLn).d();
+    NAAR = deathbft * mlyguarv - d(AVUnloaned + AVRegLn + AVPrfLn);
     NAAR = round_naar()(NAAR);
 
     CoiCharge = round_coi_charge().c(NAAR * YearsCoiRate0);
@@ -806,7 +806,7 @@ void AccountValue::TxSetRiderDed()
     AdbCharge = C0;
     if(hasadb)
         {
-        AdbCharge = round_rider_charges().c(YearsAdbRate * std::min(500000.0, 
ActualSpecAmt.d()));
+        AdbCharge = round_rider_charges().c(YearsAdbRate * std::min(500000.0, 
d(ActualSpecAmt)));
         }
 }
 
@@ -929,7 +929,7 @@ void AccountValue::TxTakeWD()
             // Carry the new spec amt forward into all future years.
             for(int j = Year; j < BasicValues::GetLength(); ++j)
                 {
-                InvariantValues().SpecAmt[j] = ActualSpecAmt.d();
+                InvariantValues().SpecAmt[j] = d(ActualSpecAmt);
                 }
             }
             break;
@@ -948,7 +948,7 @@ void AccountValue::TxTakeWD()
     wd -= std::min(WDFee, round_withdrawal().c(wd * WDFeeRate));
     // IHS !! This treats input WD as gross; it probably should be net. But 
compare lmi.
 
-    InvariantValues().NetWD[Year] = wd.d();
+    InvariantValues().NetWD[Year] = d(wd);
 // IHS !!    TaxBasis -= wd; // Withdrawals are subtracted from basis in lmi.
 }
 
@@ -972,12 +972,12 @@ void AccountValue::TxTakeLoan()
     // If maximum exceeded...limit it.
     // IHS !! For solves, the lmi branch uses an 'ullage' concept.
     double max_loan =
-          AVUnloaned.d() * 0.9    // IHS !! Icky manifest constant--lmi uses a 
database entity.
+          d(AVUnloaned) * 0.9    // IHS !! Icky manifest constant--lmi uses a 
database entity.
         // - surrchg
-        + (AVRegLn + AVPrfLn).d()
-        - RegLnBal.d() * (std::pow((1.0 + YearsRegLnIntDueRate), 12 - Month) - 
1.0)
-        - PrfLnBal.d() * (std::pow((1.0 + YearsPrfLnIntDueRate), 12 - Month) - 
1.0)
-        - mlydedtonextmodalpmtdate.d()
+        + d(AVRegLn + AVPrfLn)
+        - d(RegLnBal) * (std::pow((1.0 + YearsRegLnIntDueRate), 12 - Month) - 
1.0)
+        - d(PrfLnBal) * (std::pow((1.0 + YearsPrfLnIntDueRate), 12 - Month) - 
1.0)
+        - d(mlydedtonextmodalpmtdate)
         ;
     // Interest adjustment: d upper n where n is # months remaining in year.
     // Witholding this keeps policy from becoming overloaned before year end.
@@ -998,7 +998,7 @@ void AccountValue::TxTakeLoan()
 
     AVUnloaned -= RequestedLoan;
     AVRegLn += RequestedLoan;    // IHS !! Also preferred loans: implemented 
in lmi.
-    InvariantValues().NewCashLoan[Year] = RequestedLoan.d();
+    InvariantValues().NewCashLoan[Year] = d(RequestedLoan);
 }
 
 /// Test for lapse.
diff --git a/basicvalues.cpp b/basicvalues.cpp
index 39b6dcb..3a884fc 100644
--- a/basicvalues.cpp
+++ b/basicvalues.cpp
@@ -200,7 +200,7 @@ currency BasicValues::GetModalTgtPrem
     // IHS !! Implemented better in lmi.
     double Annuity = (1.0 - std::pow(u, 12 / a_mode)) / (1.0 - u);
 
-    double z = a_specamt.d();
+    double z = d(a_specamt);
     z /=
         (   1.0
         +   InterestRates_->GenAcctNetRate
@@ -209,7 +209,7 @@ currency BasicValues::GetModalTgtPrem
                 )[a_year]
         );
     z *= MortalityRates_->MonthlyCoiRates(mce_gen_curr)[a_year];
-    z += Loads_->monthly_policy_fee(mce_gen_curr)[a_year].d();
+    z += d(Loads_->monthly_policy_fee(mce_gen_curr)[a_year]);
 //    z += AdbRate;
 //    z *= 1.0 + WpRate;
     z /= 1.0 - Loads_->target_premium_load(mce_gen_curr)[a_year];
@@ -274,12 +274,12 @@ currency BasicValues::GetModalTgtSpecAmt
         );
     double Annuity = (1.0 - std::pow(u, 12 / a_mode)) / (1.0 - u);
 
-    double z = a_pmt.d();
+    double z = d(a_pmt);
     z /= Annuity;
     z *= 1.0 - Loads_->target_premium_load(mce_gen_curr)[0];
 //    z /= WpRate;
 //    z -= AdbRate;
-    z -= Loads_->monthly_policy_fee(mce_gen_curr)[0].d();
+    z -= d(Loads_->monthly_policy_fee(mce_gen_curr)[0]);
     z /= MortalityRates_->MonthlyCoiRates(mce_gen_curr)[0];
     z *=
         (   1.0
diff --git a/currency.hpp b/currency.hpp
index fb30ed0..8694c78 100644
--- a/currency.hpp
+++ b/currency.hpp
@@ -35,6 +35,8 @@
 
 using currency = double;
 
+inline double d(currency z) {return z;}
+
 inline std::vector<double> doubleize(std::vector<currency> const& z)
 {
     return z;
@@ -116,6 +118,8 @@ inline double operator/(currency const& lhs, double rhs)
 inline std::ostream& operator<<(std::ostream& os, currency const& z)
     {return os << z.d();}
 
+inline double d(currency z) {return z.d();}
+
 inline std::vector<double> doubleize(std::vector<currency> const& z)
 {
     std::vector<double> r;
diff --git a/currency_test.cpp b/currency_test.cpp
index 0f6f0ad..1849525 100644
--- a/currency_test.cpp
+++ b/currency_test.cpp
@@ -145,7 +145,8 @@ void currency_test::test_times_int()
 {
     // currency * int returns currency
     currency const mult2 {3125, raw_cents {}};
-    BOOST_TEST_EQUAL(1000.0, (32 * mult2).d());
+    BOOST_TEST_EQUAL(1000.0,  (32 * mult2).d());
+    BOOST_TEST_EQUAL(1000.0, d(32 * mult2));
     BOOST_TEST_EQUAL(100000, (mult2 * 32).m_);
 }
 
@@ -220,6 +221,13 @@ void currency_test::test_round_currency()
 
 void currency_test::test_quodlibet()
 {
+    currency const a0(325, raw_cents{});
+    BOOST_TEST_EQUAL(3.25, a0.d());
+    BOOST_TEST_EQUAL(3.25, d(a0));
+    currency       a1(475, raw_cents{});
+    BOOST_TEST_EQUAL(4.75, a1.d());
+    BOOST_TEST_EQUAL(4.75, d(a1));
+
     currency b0 = round_to_nearest_cent.c(464.180000000000006821);
     currency b1 = round_to_nearest_cent.c(263.01999999999998181);
     currency b2 = round_to_nearest_cent.c(0.0);
diff --git a/gpt_specamt.cpp b/gpt_specamt.cpp
index 9249c74..4dc430a 100644
--- a/gpt_specamt.cpp
+++ b/gpt_specamt.cpp
@@ -108,7 +108,7 @@ class FindSpecAmt
                     ,a_Trial
                     ,NetPmtFactorTgt
                     ,NetPmtFactorExc
-                    ,Values_.GetAnnualTgtPrem(Duration, SpecAmt).d()
+                    ,d(Values_.GetAnnualTgtPrem(Duration, SpecAmt))
                     )
             -   Premium
             ;
@@ -151,7 +151,7 @@ currency gpt_specamt::CalculateSpecAmt
         ,z
         ,a_EIOBasis
         ,a_Duration
-        ,a_Premium.d()
+        ,d(a_Premium)
         ,a_NetPmtFactorTgt
         ,a_NetPmtFactorExc
         );
diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index 8340c6e..c9e1a39 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -189,7 +189,7 @@ void AccountValue::assert_pmts_add_up(char const* file, int 
line, int month)
 #if defined CURRENCY_UNIT_IS_CENTS
                          GrossPmts[month] ==   EeGrossPmts[month]     + 
ErGrossPmts[month]
 #else  // !defined CURRENCY_UNIT_IS_CENTS
-        materially_equal(GrossPmts[month].d(), EeGrossPmts[month].d() + 
ErGrossPmts[month].d())
+        materially_equal(d(GrossPmts[month]), d(EeGrossPmts[month]) + 
d(ErGrossPmts[month]))
 #endif // !defined CURRENCY_UNIT_IS_CENTS
         ;
     if(okay)
@@ -258,7 +258,7 @@ void AccountValue::SetGuarPrem()
         }
     // bignum: the largest integer convertible to and from double.
     LMI_ASSERT(GuarPremium < currency(1LL << 53, raw_cents{}));
-    ledger_->SetGuarPremium(GuarPremium.d());
+    ledger_->SetGuarPremium(d(GuarPremium));
 }
 
 //============================================================================
@@ -428,12 +428,12 @@ void AccountValue::InitializeLife(mcenum_run_basis 
a_Basis)
     SurrChg_.assign(BasicValues::GetLength(), C0);
 
     // TAXATION !! Input::InforceAnnualTargetPremium should be used here.
-    double annual_target_premium = GetModalTgtPrem
+    double annual_target_premium = d(GetModalTgtPrem
         (0
         ,mce_annual
         ,base_specamt(0)
-        ).d();
-    double sa = specamt_for_7702(0).d();
+        ));
+    double sa = d(specamt_for_7702(0));
 
     // It is at best superfluous to do this for every basis.
     // TAXATION !! Don't do that then.
@@ -477,7 +477,7 @@ void AccountValue::InitializeLife(mcenum_run_basis a_Basis)
     if(yare_input_.EffectiveDate == yare_input_.InforceAsOfDate)
         {
         // No need to initialize 'pmts_7702a' in this case.
-        bfts_7702a.push_back(specamt_for_7702A(0).d());
+        bfts_7702a.push_back(d(specamt_for_7702A(0)));
         }
     else
         {
@@ -933,7 +933,7 @@ void AccountValue::InitializeSpecAmt()
 
     if(0 == Year)
         {
-        InvariantValues().InitTgtPrem = AnnualTargetPrem.d();
+        InvariantValues().InitTgtPrem = d(AnnualTargetPrem);
         }
 
     // TODO ?? Perform specamt strategy here?
@@ -972,8 +972,8 @@ void AccountValue::set_list_bill_premium()
             ,Outlay_->er_premium_modes()[Year]
             ,base_specamt(Year)
             );
-        InvariantValues().ListBillPremium   = z.d();
-        InvariantValues().ErListBillPremium = z.d();
+        InvariantValues().ListBillPremium   = d(z);
+        InvariantValues().ErListBillPremium = d(z);
         }
     else
         {
@@ -983,9 +983,9 @@ void AccountValue::set_list_bill_premium()
             ,base_specamt(Year)
             ,term_specamt(Year)
             );
-        InvariantValues().EeListBillPremium = z.first.d();
-        InvariantValues().ErListBillPremium = z.second.d();
-        InvariantValues().ListBillPremium = z.first.d() + z.second.d();
+        InvariantValues().EeListBillPremium = d(z.first);
+        InvariantValues().ErListBillPremium = d(z.second);
+        InvariantValues().ListBillPremium = d(z.first) + d(z.second);
         }
 }
 
@@ -1010,8 +1010,8 @@ void AccountValue::set_modal_min_premium()
             ,Outlay_->er_premium_modes()[Year]
             ,base_specamt(Year)
             );
-        InvariantValues().ModalMinimumPremium[Year]   = z.d();
-        InvariantValues().ErModalMinimumPremium[Year] = z.d();
+        InvariantValues().ModalMinimumPremium[Year]   = d(z);
+        InvariantValues().ErModalMinimumPremium[Year] = d(z);
         }
     else
         {
@@ -1021,9 +1021,9 @@ void AccountValue::set_modal_min_premium()
             ,base_specamt(Year)
             ,term_specamt(Year)
             );
-        InvariantValues().EeModalMinimumPremium[Year] = z.first.d();
-        InvariantValues().ErModalMinimumPremium[Year] = z.second.d();
-        InvariantValues().ModalMinimumPremium[Year] = z.first.d() + 
z.second.d();
+        InvariantValues().EeModalMinimumPremium[Year] = d(z.first);
+        InvariantValues().ErModalMinimumPremium[Year] = d(z.second);
+        InvariantValues().ModalMinimumPremium[Year] = d(z.first) + d(z.second);
         }
 }
 
@@ -1151,8 +1151,8 @@ void AccountValue::SetProjectedCoiCharge()
     TxSetTermAmt();
     // presumably material_difference() isn't needed at all? um...yes, it is
     double this_years_terminal_naar = material_difference
-        ((DBReflectingCorr + TermDB).d()
-        ,(TotalAccountValue()).d()
+        (d((DBReflectingCorr + TermDB))
+        ,d(TotalAccountValue())
         );
     this_years_terminal_naar = std::max(0.0, this_years_terminal_naar);
     double next_years_coi_rate = GetBandedCoiRates(GenBasis_, ActualSpecAmt)[1 
+ Year];
@@ -1186,7 +1186,7 @@ void AccountValue::SetProjectedCoiCharge()
 
 void AccountValue::FinalizeYear()
 {
-    VariantValues().TotalLoanBalance[Year] = (RegLnBal + PrfLnBal).d();
+    VariantValues().TotalLoanBalance[Year] = d(RegLnBal + PrfLnBal);
 
     currency total_av = TotalAccountValue();
     currency surr_chg = SurrChg();
@@ -1242,12 +1242,12 @@ void AccountValue::FinalizeYear()
         }
     cv_7702 = std::max(cv_7702, HoneymoonValue);
 
-    VariantValues().AcctVal     [Year] = total_av.d();
-    VariantValues().AVGenAcct   [Year] = (AVGenAcct + AVRegLn + AVPrfLn).d();
-    VariantValues().AVSepAcct   [Year] = AVSepAcct.d();
+    VariantValues().AcctVal     [Year] = d(total_av);
+    VariantValues().AVGenAcct   [Year] = d(AVGenAcct + AVRegLn + AVPrfLn);
+    VariantValues().AVSepAcct   [Year] = d(AVSepAcct);
     VariantValues().DacTaxRsv   [Year] = DacTaxRsv;
-    VariantValues().CSVNet      [Year] = csv_net.d();
-    VariantValues().CV7702      [Year] = cv_7702.d();
+    VariantValues().CSVNet      [Year] = d(csv_net);
+    VariantValues().CV7702      [Year] = d(cv_7702);
 
     // Update death benefit. 'DBReflectingCorr' currently equals the
     // death benefit as of the beginning of the twelfth month, but its
@@ -1257,11 +1257,11 @@ void AccountValue::FinalizeYear()
     TxSetDeathBft();
     TxSetTermAmt();
     // post values to LedgerVariant
-    InvariantValues().TermSpecAmt   [Year] = TermSpecAmt.d();
-    VariantValues().TermPurchased   [Year] = TermDB.d();
+    InvariantValues().TermSpecAmt   [Year] = d(TermSpecAmt);
+    VariantValues().TermPurchased   [Year] = d(TermDB);
     // Add term rider DB
-    VariantValues().BaseDeathBft    [Year] = DBReflectingCorr.d();
-    VariantValues().EOYDeathBft     [Year] = (DBReflectingCorr + TermDB).d();
+    VariantValues().BaseDeathBft    [Year] = d(DBReflectingCorr);
+    VariantValues().EOYDeathBft     [Year] = d(DBReflectingCorr + TermDB);
 
 /*
     // AV already includes any experience refund credited, but it's
@@ -1286,19 +1286,19 @@ void AccountValue::FinalizeYear()
 
     // Monthly deduction detail
 
-    VariantValues().COICharge         [Year] = YearsTotalCoiCharge.d()    ;
-    VariantValues().RiderCharges      [Year] = YearsTotalRiderCharges.d() ;
+    VariantValues().COICharge         [Year] = d(YearsTotalCoiCharge)    ;
+    VariantValues().RiderCharges      [Year] = d(YearsTotalRiderCharges) ;
     VariantValues().AVRelOnDeath      [Year] = YearsAVRelOnDeath          ;
     VariantValues().ClaimsPaid        [Year] = YearsGrossClaims           ;
     VariantValues().DeathProceedsPaid [Year] = YearsDeathProceeds         ;
     VariantValues().NetClaims         [Year] = YearsNetClaims             ;
-    VariantValues().NetIntCredited    [Year] = YearsTotalNetIntCredited.d();
-    VariantValues().GrossIntCredited  [Year] = YearsTotalGrossIntCredited.d();
-    VariantValues().LoanIntAccrued    [Year] = YearsTotalLoanIntAccrued.d();
+    VariantValues().NetIntCredited    [Year] = d(YearsTotalNetIntCredited);
+    VariantValues().GrossIntCredited  [Year] = d(YearsTotalGrossIntCredited);
+    VariantValues().LoanIntAccrued    [Year] = d(YearsTotalLoanIntAccrued);
     VariantValues().NetCOICharge      [Year] = YearsTotalNetCoiCharge     ;
-    VariantValues().PolicyFee         [Year] = YearsTotalPolicyFee.d()    ;
+    VariantValues().PolicyFee         [Year] = d(YearsTotalPolicyFee)    ;
     VariantValues().DacTaxLoad        [Year] = YearsTotalDacTaxLoad       ;
-    VariantValues().SpecAmtLoad       [Year] = YearsTotalSpecAmtLoad.d()  ;
+    VariantValues().SpecAmtLoad       [Year] = d(YearsTotalSpecAmtLoad)  ;
     VariantValues().PremTaxLoad       [Year] = PremiumTax_->ytd_load();
 
     currency notional_sep_acct_charge =
@@ -1308,14 +1308,14 @@ void AccountValue::FinalizeYear()
         ;
 #if 0 // not needed--already currency
     double notional_sep_acct_charge =
-          YearsTotalSepAcctLoad.d()
+          d(YearsTotalSepAcctLoad)
         + material_difference
             (YearsTotalGrossIntCredited
             ,YearsTotalNetIntCredited
             )
         ;
 #endif // 0
-    VariantValues().SepAcctCharges    [Year] = notional_sep_acct_charge.d();
+    VariantValues().SepAcctCharges    [Year] = d(notional_sep_acct_charge);
 
     // Record dynamic interest rate in ledger object.
     //
@@ -1349,11 +1349,11 @@ void AccountValue::FinalizeYear()
             );
         }
 
-    VariantValues().NetPmt[Year] = std::accumulate
+    VariantValues().NetPmt[Year] = d(std::accumulate
         (NetPmts.begin()
         ,NetPmts.end()
         ,-YearsTotalGptForceout
-        ).d();
+        ));
 
     if(mce_run_gen_curr_sep_full == RunBasis_)
         {
@@ -1365,15 +1365,15 @@ void AccountValue::FinalizeYear()
         // Forceouts should be a distinct component, passed separately
         // to ledger values. Probably we should treat 1035 exchanges
         // and NAAR 'forceouts' the same way.
-        InvariantValues().GrossPmt  [Year]  -= YearsTotalGptForceout.d();
-        InvariantValues().EeGrossPmt[Year]  -= YearsTotalGptForceout.d();
+        InvariantValues().GrossPmt  [Year]  -= d(YearsTotalGptForceout);
+        InvariantValues().EeGrossPmt[Year]  -= d(YearsTotalGptForceout);
 
         for(int j = 0; j < 12; ++j)
             {
             assert_pmts_add_up(__FILE__, __LINE__, j);
-            InvariantValues().GrossPmt  [Year]  += GrossPmts  [j].d();
-            InvariantValues().EeGrossPmt[Year]  += EeGrossPmts[j].d();
-            InvariantValues().ErGrossPmt[Year]  += ErGrossPmts[j].d();
+            InvariantValues().GrossPmt  [Year]  += d(GrossPmts  [j]);
+            InvariantValues().EeGrossPmt[Year]  += d(EeGrossPmts[j]);
+            InvariantValues().ErGrossPmt[Year]  += d(ErGrossPmts[j]);
             }
         if(0 == Year)
             {
@@ -1394,7 +1394,7 @@ void AccountValue::FinalizeYear()
             -   InvariantValues().NewCashLoan[Year]
             ;
 
-        InvariantValues().GptForceout[Year] = YearsTotalGptForceout.d();
+        InvariantValues().GptForceout[Year] = d(YearsTotalGptForceout);
 
 // SOMEDAY !! Not yet implemented.
 //        InvariantValues().NaarForceout[Year] = 
InvariantValues().ErGrossPmt[Year];
diff --git a/ihs_avdebug.cpp b/ihs_avdebug.cpp
index 3bec972..81a8f2d 100644
--- a/ihs_avdebug.cpp
+++ b/ihs_avdebug.cpp
@@ -261,7 +261,7 @@ inline void AccountValue::SetMonthlyDetail(int enumerator, 
double d)
 inline void AccountValue::SetMonthlyDetail(int enumerator, currency c)
 {
     // CURRENCY !! Probably value_cast<>(currency) should be specialized.
-    DebugRecord[enumerator] = value_cast<std::string>(c.d());
+    DebugRecord[enumerator] = value_cast<std::string>(d(c));
 }
 #endif // defined USE_CURRENCY_CLASS
 
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index 13ec3ed..5d75a1a 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -120,14 +120,14 @@ void AccountValue::DoMonthDR()
     // TAXATION !! Is it really useful to comment the arguments here?
     Irc7702A_->UpdateBft7702A
         (Dcv
-        ,(DBReflectingCorr + TermDB).d() // DB7702A
-        ,OldDB.d() // prior_db_7702A
+        ,d(DBReflectingCorr + TermDB) // DB7702A
+        ,d(OldDB) // prior_db_7702A
         ,DBReflectingCorr == DBIgnoringCorr
         // TAXATION !! This assumes the term rider can be treated as death 
benefit;
         // use 'TermIsDbFor7702A'.
-        ,(ActualSpecAmt + TermSpecAmt).d()
-        ,OldSA.d() // prior_sa_7702A
-        ,CashValueFor7702().d()
+        ,d(ActualSpecAmt + TermSpecAmt)
+        ,d(OldSA) // prior_sa_7702A
+        ,d(CashValueFor7702())
         );
 
     NetPmts  [Month] = C0; // TODO ?? expunge as being unnecessary
@@ -154,20 +154,20 @@ void AccountValue::DoMonthDR()
     // Not already rounded by class Irc7702A.
     double max_necessary_premium = Irc7702A_->MaxNecessaryPremium
         (Dcv
-        ,AnnualTargetPrem.d()
+        ,d(AnnualTargetPrem)
         ,YearsTotLoadTgtLowestPremtax
         ,YearsTotLoadExcLowestPremtax
-        ,kludge_account_value.d()
+        ,d(kludge_account_value)
         );
 // TAXATION !! Should round here, but need to investigate regressions.
 //  max_necessary_premium = round_max_premium()(max_necessary_premium);
     // Already rounded by class Irc7702A.
     double max_non_mec_premium = Irc7702A_->MaxNonMecPremium
         (Dcv
-        ,AnnualTargetPrem.d()
+        ,d(AnnualTargetPrem)
         ,YearsTotLoadTgtLowestPremtax
         ,YearsTotLoadExcLowestPremtax
-        ,kludge_account_value.d()
+        ,d(kludge_account_value)
         );
 
     // Saved for monthly detail report only. TAXATION !! Then are
@@ -191,12 +191,12 @@ void AccountValue::DoMonthDR()
         {
         Irc7702A_->UpdatePmt7702A
             (Dcv
-            ,-NetWD.d() // TAXATION !! This should be gross, not net.
+            ,-d(NetWD) // TAXATION !! This should be gross, not net.
             ,false
-            ,AnnualTargetPrem.d()
+            ,d(AnnualTargetPrem)
             ,YearsTotLoadTgtLowestPremtax
             ,YearsTotLoadExcLowestPremtax
-            ,kludge_account_value.d()
+            ,d(kludge_account_value)
             );
         }
 
@@ -207,14 +207,14 @@ void AccountValue::DoMonthDR()
         }
     double necessary_premium = std::min // round?
         (material_difference // round?
-            (GrossPmts[Month].d()
-            ,gross_1035.d()
+            (d(GrossPmts[Month])
+            ,d(gross_1035)
             )
         ,max_necessary_premium
         );
     double unnecessary_premium = material_difference // round?
-        (GrossPmts[Month].d()
-        ,gross_1035.d() + necessary_premium
+        (d(GrossPmts[Month])
+        ,d(gross_1035) + necessary_premium
         );
 //  NetMaxNecessaryPremium
 //  GrossMaxNecessaryPremium
@@ -251,7 +251,7 @@ void AccountValue::DoMonthDR()
         (Dcv // Potentially modified.
         ,unnecessary_premium
         ,necessary_premium
-        ,CashValueFor7702().d()
+        ,d(CashValueFor7702())
         );
     LMI_ASSERT(0.0 <= Dcv);
 
@@ -305,7 +305,7 @@ void AccountValue::process_payment(currency payment)
     double er_proportion = 0.0;
     if(C0 != gross_non_1035_pmts)
         {
-        er_proportion = ErGrossPmts[Month] / gross_non_1035_pmts.d();
+        er_proportion = ErGrossPmts[Month] / d(gross_non_1035_pmts);
         }
 
     // This is a net premium that's multiplied by a gross-premium
@@ -361,8 +361,8 @@ void AccountValue::IncrementAVProportionally(currency 
increment)
     AVGenAcct += genacct_increment;
     AVSepAcct += increment - genacct_increment;
 #if !defined CURRENCY_UNIT_IS_CENTS
-    AVSepAcct = round_minutiae().c(AVSepAcct.d());
-    if(0.0 == AVSepAcct.d()) AVSepAcct = C0; // Negate negative zeroes.
+    AVSepAcct = round_minutiae().c(d(AVSepAcct));
+    if(0.0 == d(AVSepAcct)) AVSepAcct = C0; // Negate negative zeroes.
 #endif // !defined CURRENCY_UNIT_IS_CENTS
 }
 
@@ -453,8 +453,8 @@ void AccountValue::DecrementAVProportionally(currency 
decrement)
 
     double general_account_proportion  = 0.0;
     double separate_account_proportion = 0.0;
-    double general_account_nonnegative_assets  = std::max(0.0, AVGenAcct.d());
-    double separate_account_nonnegative_assets = std::max(0.0, AVSepAcct.d());
+    double general_account_nonnegative_assets  = std::max(0.0, d(AVGenAcct));
+    double separate_account_nonnegative_assets = std::max(0.0, d(AVSepAcct));
     if
         (  0.0 == general_account_nonnegative_assets
         && 0.0 == separate_account_nonnegative_assets
@@ -491,8 +491,8 @@ void AccountValue::DecrementAVProportionally(currency 
decrement)
     AVGenAcct -= genacct_decrement;
     AVSepAcct -= decrement - genacct_decrement;
 #if !defined CURRENCY_UNIT_IS_CENTS
-    AVSepAcct = round_minutiae().c(AVSepAcct.d());
-    if(0.0 == AVSepAcct.d()) AVSepAcct = C0; // Negate negative zeroes.
+    AVSepAcct = round_minutiae().c(d(AVSepAcct));
+    if(0.0 == d(AVSepAcct)) AVSepAcct = C0; // Negate negative zeroes.
 #endif // !defined CURRENCY_UNIT_IS_CENTS
 }
 
@@ -568,7 +568,7 @@ void AccountValue::TxExch1035()
         if(!SolvingForGuarPremium)
             {
             // Maybe this should return the modified value instead of altering 
the argument.
-            double z = GrossPmts[Month].d();
+            double z = d(GrossPmts[Month]);
             Irc7702_->ProcessGptPmt(Year, z);
             GrossPmts[Month] = round_gross_premium().c(z);
             }
@@ -613,10 +613,10 @@ void AccountValue::TxExch1035()
     LMI_ASSERT(0.0 == Dcv);
     Irc7702A_->Update1035Exch7702A
         (Dcv
-        ,NetPmts[Month].d()
+        ,d(NetPmts[Month])
         // TAXATION !! This assumes the term rider can be treated as death 
benefit;
         // use 'TermIsDbFor7702A'.
-        ,(ActualSpecAmt + TermSpecAmt).d()
+        ,d(ActualSpecAmt + TermSpecAmt)
 //        ,DBReflectingCorr + TermDB // TAXATION !! Alternate if 7702A benefit 
is DB?
         );
 
@@ -637,7 +637,7 @@ void AccountValue::TxExch1035()
         // Immediately after a 1035 exchange, DCV should be
         // the 1035 amount reduced by any premium-based loads,
         // but only for the current rate basis.
-        LMI_ASSERT(materially_equal(Dcv, NetPmts[Month].d()));
+        LMI_ASSERT(materially_equal(Dcv, d(NetPmts[Month])));
 
         // The initial seven-pay premium shown on the illustration
         // must be its value immediately after any 1035 exchange,
@@ -746,7 +746,7 @@ void AccountValue::ChangeSpecAmtBy(currency delta)
                 break;
             case mce_adjust_both:
                 {
-                term_proportion = TermSpecAmt / old_total_specamt.d();
+                term_proportion = TermSpecAmt / d(old_total_specamt);
                 }
                 break;
             case mce_adjust_base:
@@ -804,12 +804,12 @@ void AccountValue::ChangeSpecAmtBy(currency delta)
 // TODO ?? Shouldn't this be moved to FinalizeMonth()? The problem is
 // that the ledger object is used for working storage, where it should
 // probably be write-only instead.
-        InvariantValues().SpecAmt[j] = ActualSpecAmt.d();
+        InvariantValues().SpecAmt[j] = d(ActualSpecAmt);
         // Adjust term here only if it's formally a rider.
         // Otherwise, its amount should not have been changed.
         if(!TermIsNotRider)
             {
-            InvariantValues().TermSpecAmt[j] = TermSpecAmt.d();
+            InvariantValues().TermSpecAmt[j] = d(TermSpecAmt);
             }
 // Term specamt is a vector in class LedgerInvariant, but a scalar in
 // the input classes, e.g.:
@@ -836,7 +836,7 @@ void AccountValue::ChangeSupplAmtBy(currency delta)
     // Carry the new supplemental amount forward into all future years.
     for(int j = Year; j < BasicValues::GetLength(); ++j)
         {
-        InvariantValues().TermSpecAmt[j] = TermSpecAmt.d();
+        InvariantValues().TermSpecAmt[j] = d(TermSpecAmt);
         }
     // Reset term DB whenever term SA changes. It's not obviously
     // necessary to do this here, but neither should it do any harm.
@@ -1140,15 +1140,15 @@ void AccountValue::TxTestGPT()
         // Or maybe not, because we can't match it if there was a plan change.
         Irc7702_->ProcessAdjustableEvent
             (Year
-            ,(DBReflectingCorr + TermDB).d()
-            ,OldDB.d()
+            ,d(DBReflectingCorr + TermDB)
+            ,d(OldDB)
             // TAXATION !! This assumes the term rider can be treated as death 
benefit;
             // use 'TermIsDbFor7702'.
-            ,(ActualSpecAmt + TermSpecAmt).d()
-            ,OldSA.d()
+            ,d(ActualSpecAmt + TermSpecAmt)
+            ,d(OldSA)
             ,new_dbopt
             ,old_dbopt
-            ,AnnualTargetPrem.d()
+            ,d(AnnualTargetPrem)
             );
         }
 
@@ -1242,7 +1242,7 @@ void AccountValue::TxAscertainDesiredPayment()
         // Illustration-reg guaranteed premium ignores GPT limit.
         if(!SolvingForGuarPremium)
             {
-            double z = eepmt.d();
+            double z = d(eepmt);
             Irc7702_->ProcessGptPmt(Year, z);
             eepmt = round_gross_premium().c(z);
             }
@@ -1257,7 +1257,7 @@ void AccountValue::TxAscertainDesiredPayment()
         // Illustration-reg guaranteed premium ignores GPT limit.
         if(!SolvingForGuarPremium)
             {
-            double z = erpmt.d();
+            double z = d(erpmt);
             Irc7702_->ProcessGptPmt(Year, z);
             erpmt = round_gross_premium().c(z);
             }
@@ -1284,7 +1284,7 @@ void AccountValue::TxAscertainDesiredPayment()
         // Illustration-reg guaranteed premium ignores GPT limit.
         if(!SolvingForGuarPremium)
             {
-            double z = Dumpin.d();
+            double z = d(Dumpin);
             Irc7702_->ProcessGptPmt(Year, z);
             Dumpin = round_gross_premium().c(z);
             }
@@ -1322,7 +1322,7 @@ void AccountValue::TxLimitPayment(double a_maxpmt)
             gross_1035 = External1035Amount + Internal1035Amount;
             }
         currency gross_pmt_without_1035 = GrossPmts[Month] - gross_1035;
-        gross_pmt_without_1035 = 
round_gross_premium().c(std::min(gross_pmt_without_1035.d(), a_maxpmt));
+        gross_pmt_without_1035 = 
round_gross_premium().c(std::min(d(gross_pmt_without_1035), a_maxpmt));
         // TODO ?? For now at least, reduce employee premium first.
         progressively_limit
             (EeGrossPmts[Month]
@@ -1387,12 +1387,12 @@ void AccountValue::TxRecognizePaymentFor7702A
     currency amount_paid_7702A = a_pmt;
     Irc7702A_->UpdatePmt7702A
         (Dcv
-        ,amount_paid_7702A.d()
+        ,d(amount_paid_7702A)
         ,a_this_payment_is_unnecessary
-        ,AnnualTargetPrem.d()
+        ,d(AnnualTargetPrem)
         ,YearsTotLoadTgtLowestPremtax
         ,YearsTotLoadExcLowestPremtax
-        ,kludge_account_value.d()
+        ,d(kludge_account_value)
         );
 }
 
@@ -1428,7 +1428,7 @@ void AccountValue::TxAcceptPayment(currency a_pmt)
 
     process_payment(net_pmt);
 
-    Dcv += std::max(0.0, net_pmt.d());
+    Dcv += std::max(0.0, d(net_pmt));
     LMI_ASSERT(0.0 <= Dcv);
 
     if(HoneymoonActive)
@@ -1505,7 +1505,7 @@ currency AccountValue::GetPremLoad
     CumulativeSalesLoad += round_net_premium().c(sales_load_);
 
     premium_tax_load_ = PremiumTax_->calculate_load
-        ((a_pmt - a_portion_exempt_from_premium_tax).d()
+        (d(a_pmt - a_portion_exempt_from_premium_tax)
         ,*StratifiedCharges_
         );
 
@@ -1577,7 +1577,7 @@ void AccountValue::TxLoanRepay()
 // This seems wrong. If we're changing something that's invariant among
 // bases, why do we change it for each basis?
 // TODO ?? Shouldn't this be moved to FinalizeMonth()?
-    InvariantValues().NewCashLoan[Year] = ActualLoan.d();
+    InvariantValues().NewCashLoan[Year] = d(ActualLoan);
     // TODO ?? Consider changing loan_ullage_[Year] here.
 }
 
@@ -1602,10 +1602,10 @@ void AccountValue::TxSetBOMAV()
             std::min
                 (   SpecAmtLoadLimit
                 ,   (0 == Year && 0 == Month)
-                    ? std::max
+                    ? d(std::max
                         (term_specamt(0) + base_specamt(0)
                         ,round_death_benefit().c(NetPmts[0] * 
YearsCorridorFactor)
-                        ).d()
+                        ))
                     : yare_input_.InforceSpecAmtLoadBase
                 )
             );
@@ -1625,7 +1625,7 @@ void AccountValue::TxSetBOMAV()
 
     process_deduction(MonthsPolicyFees + SpecAmtLoad);
 
-    Dcv -= (MonthsPolicyFees + SpecAmtLoad).d();
+    Dcv -= d(MonthsPolicyFees + SpecAmtLoad);
     Dcv = std::max(0.0, Dcv);
 }
 
@@ -1723,12 +1723,12 @@ void AccountValue::TxSetDeathBft()
     DB7702A = DBReflectingCorr + TermDB;
 
     DcvDeathBft = std::max
-        (DBIgnoringCorr.d()
+        (d(DBIgnoringCorr)
         ,   (
                 YearsCorridorFactor
             *   (   Dcv
-                -   std::min(C0, SurrChg()).d()
-                +   GetRefundableSalesLoad().d()
+                -   d(std::min(C0, SurrChg()))
+                +   d(GetRefundableSalesLoad())
 //                +   std::max(0.0, ExpRatReserve) // This would be added if 
it existed.
                 )
             )
@@ -1797,7 +1797,7 @@ void AccountValue::EndTermRider(bool convert)
     // Carry the new term spec amt forward into all future years.
     for(int j = Year; j < BasicValues::GetLength(); ++j)
         {
-        InvariantValues().TermSpecAmt[j] = TermSpecAmt.d();
+        InvariantValues().TermSpecAmt[j] = d(TermSpecAmt);
         }
 }
 
@@ -1817,7 +1817,7 @@ void AccountValue::TxSetCoiCharge()
     // the account value by deducting a negative mortality charge.
     NAAR = material_difference
         (DBReflectingCorr * DBDiscountRate[Year]
-        ,std::max(0.0, TotalAccountValue().d())
+        ,std::max(0.0, d(TotalAccountValue()))
         );
     NAAR = std::max(0.0, round_naar()(NAAR));
 
@@ -1827,7 +1827,7 @@ void AccountValue::TxSetCoiCharge()
 // TAXATION !! Should this be handled at the same time as GPT forceouts?
 
     DcvNaar = material_difference
-        (std::max(DcvDeathBft, DBIgnoringCorr.d()) * DBDiscountRate[Year]
+        (std::max(DcvDeathBft, d(DBIgnoringCorr)) * DBDiscountRate[Year]
         ,std::max(0.0, Dcv)
         );
     // DCV need not be rounded.
@@ -1876,7 +1876,7 @@ void AccountValue::TxSetRiderDed()
     if(yare_input_.AccidentalDeathBenefit)
         {
         AdbCharge = round_rider_charges().c
-            (YearsAdbRate * std::min(ActualSpecAmt.d(), AdbLimit)
+            (YearsAdbRate * std::min(d(ActualSpecAmt), AdbLimit)
             );
         }
 
@@ -1919,9 +1919,9 @@ void AccountValue::TxSetRiderDed()
             case oe_waiver_times_specamt:
                 {
                 WpCharge = round_rider_charges().c
-                    (YearsWpRate * std::min(ActualSpecAmt.d(), WpLimit)
+                    (YearsWpRate * std::min(d(ActualSpecAmt), WpLimit)
                     );
-                DcvWpCharge = WpCharge.d();
+                DcvWpCharge = d(WpCharge);
                 }
                 break;
             case oe_waiver_times_deductions:
@@ -1945,11 +1945,11 @@ void AccountValue::TxSetRiderDed()
                     YearsWpRate
                     *   (
                             DcvCoiCharge
-                        +   MonthsPolicyFees.d()
-                        +   SpecAmtLoad.d()
-                        +   AdbCharge.d()
-                        +   SpouseRiderCharge.d()
-                        +   ChildRiderCharge.d()
+                        +   d(MonthsPolicyFees)
+                        +   d(SpecAmtLoad)
+                        +   d(AdbCharge)
+                        +   d(SpouseRiderCharge)
+                        +   d(ChildRiderCharge)
                         +   DcvTermCharge
                         );
                 }
@@ -1977,7 +1977,7 @@ void AccountValue::TxDoMlyDed()
 
     double dcv_mly_ded =
             DcvCoiCharge
-        +   simple_rider_charges.d()
+        +   d(simple_rider_charges)
         +   DcvTermCharge
         +   DcvWpCharge
         ;
@@ -1998,7 +1998,7 @@ void AccountValue::TxDoMlyDed()
     // determined.
     MlyDed += MonthsPolicyFees + SpecAmtLoad;
 
-    YearsTotalNetCoiCharge += NetCoiCharge.d();
+    YearsTotalNetCoiCharge += d(NetCoiCharge);
 
     SepAcctValueAfterDeduction = AVSepAcct;
 }
@@ -2061,15 +2061,15 @@ void AccountValue::TxTakeSepAcctLoad()
         {
         double stratified_load = StratifiedCharges_->stratified_sepacct_load
             (GenBasis_
-            ,AssetsPostBom.d()
-            ,CumPmtsPostBom.d()
+            ,d(AssetsPostBom)
+            ,d(CumPmtsPostBom)
             ,database().query<double>(DB_DynSepAcctLoadLimit)
             );
 
         double tiered_comp = 0.0;
         if(oe_asset_charge_load == 
database().query<oenum_asset_charge_type>(DB_AssetChargeType))
             {
-            tiered_comp = 
StratifiedCharges_->tiered_asset_based_compensation(AssetsPostBom.d());
+            tiered_comp = 
StratifiedCharges_->tiered_asset_based_compensation(d(AssetsPostBom));
             }
         if(0.0 != tiered_comp)
             {
@@ -2097,7 +2097,7 @@ void AccountValue::TxTakeSepAcctLoad()
     // Does this seem right? Mightn't it take a sepacct load from the genacct?
     process_deduction(SepAcctLoad);
     YearsTotalSepAcctLoad += SepAcctLoad;
-    Dcv -= SepAcctLoad.d();
+    Dcv -= d(SepAcctLoad);
     Dcv = std::max(0.0, Dcv);
 }
 
@@ -2138,8 +2138,8 @@ void AccountValue::ApplyDynamicMandE(currency assets)
 
     // Annual separate-account rates.
 
-    double m_and_e_rate = StratifiedCharges_->tiered_m_and_e(GenBasis_, 
assets.d());
-    double imf_rate = 
StratifiedCharges_->tiered_investment_management_fee(assets.d());
+    double m_and_e_rate = StratifiedCharges_->tiered_m_and_e(GenBasis_, 
d(assets));
+    double imf_rate = 
StratifiedCharges_->tiered_investment_management_fee(d(assets));
     if(0.0 != imf_rate)
         {
         alarum()
@@ -2149,7 +2149,7 @@ void AccountValue::ApplyDynamicMandE(currency assets)
         }
     double asset_comp_rate =
         (oe_asset_charge_spread == 
database().query<oenum_asset_charge_type>(DB_AssetChargeType))
-            ? StratifiedCharges_->tiered_asset_based_compensation(assets.d())
+            ? StratifiedCharges_->tiered_asset_based_compensation(d(assets))
             : 0.0
             ;
     if(0.0 != asset_comp_rate)
@@ -2355,12 +2355,12 @@ void AccountValue::SetMaxWD()
     double max_wd =
           AVGenAcct * MaxWdGenAcctValMult
         + AVSepAcct * MaxWdSepAcctValMult
-        + (AVRegLn  + AVPrfLn).d()
-        - (RegLnBal + PrfLnBal).d()
-        - anticipated_deduction(MaxWDDed_).d()
-        - std::max(0.0, SurrChg().d())
+        + d(AVRegLn  + AVPrfLn)
+        - d(RegLnBal + PrfLnBal)
+        - d(anticipated_deduction(MaxWDDed_))
+        - d(std::max(C0, SurrChg()))
         ;
-    if(max_wd < MinWD.d())
+    if(max_wd < d(MinWD))
         {
         max_wd = 0.0;
         }
@@ -2536,14 +2536,14 @@ void AccountValue::TxTakeWD()
         return;
         }
 
-    GrossWD = round_withdrawal().c(NetWD.d() + std::min(WDFee.d(), NetWD * 
WDFeeRate));
+    GrossWD = round_withdrawal().c(d(NetWD) + std::min(d(WDFee), NetWD * 
WDFeeRate));
 
     // Free partial surrenders: for instance, the first 20% of account
     // value might be withdrawn each policy year free of surrender
     // charge. This would become more complicated if we maintained
     // distinct surrender-charge layers.
 
-    double surrchg_proportion = SurrChg_[Year] / csv.d();
+    double surrchg_proportion = SurrChg_[Year] / d(csv);
     currency non_free_wd = GrossWD;
     if(0.0 != FreeWDProportion[Year])
         {
@@ -2560,7 +2560,7 @@ void AccountValue::TxTakeWD()
     GrossWD += round_withdrawal().c(partial_surrchg);
 
     process_distribution(GrossWD);
-    Dcv -= GrossWD.d();
+    Dcv -= d(GrossWD);
     Dcv = std::max(0.0, Dcv);
 
     switch(YearsDBOpt)
@@ -2642,7 +2642,7 @@ void AccountValue::TxTakeWD()
             {
             // TODO ?? TAXATION !! What if reference argument
             // 'premiums_paid_increment' is modified?
-            double premiums_paid_increment = 0.0 - GrossWD.d();
+            double premiums_paid_increment = 0.0 - d(GrossWD);
             Irc7702_->ProcessGptPmt(Year, premiums_paid_increment);
             }
         }
@@ -2650,7 +2650,7 @@ void AccountValue::TxTakeWD()
 // This seems wrong. If we're changing something that's invariant among
 // bases, why do we change it for each basis?
 // TODO ?? Shouldn't this be moved to FinalizeMonth()?
-    InvariantValues().NetWD[Year] = NetWD.d();
+    InvariantValues().NetWD[Year] = d(NetWD);
 }
 
 //============================================================================
@@ -2658,10 +2658,10 @@ void AccountValue::TxTakeWD()
 void AccountValue::SetMaxLoan()
 {
     double max_loan =
-          (AVGenAcct + AVSepAcct).d() * MaxLoanAVMult
-        + (AVRegLn + AVPrfLn).d()
-        - anticipated_deduction(MaxLoanDed_).d()
-        - std::max(C0, SurrChg()).d()
+          d(AVGenAcct + AVSepAcct) * MaxLoanAVMult
+        + d(AVRegLn + AVPrfLn)
+        - d(anticipated_deduction(MaxLoanDed_))
+        - d(std::max(C0, SurrChg()))
         ;
 
     // Illustrations generally permit loans only on anniversary.
@@ -2754,7 +2754,7 @@ void AccountValue::TxTakeLoan()
         ActualLoan = std::min(max_loan_increment, RequestedLoan);
         ActualLoan = std::max(ActualLoan, C0);
         // TODO ?? Shouldn't this happen in FinalizeMonth()?
-        InvariantValues().NewCashLoan[Year] = ActualLoan.d();
+        InvariantValues().NewCashLoan[Year] = d(ActualLoan);
         }
 
     {
@@ -2930,9 +2930,9 @@ void AccountValue::FinalizeMonth()
         {
         if(0 == Year && 0 == Month)
             {
-            InvariantValues().External1035Amount = External1035Amount.d();
-            InvariantValues().Internal1035Amount = Internal1035Amount.d();
-            InvariantValues().Dumpin = Dumpin.d();
+            InvariantValues().External1035Amount = d(External1035Amount);
+            InvariantValues().Internal1035Amount = d(Internal1035Amount);
+            InvariantValues().Dumpin = d(Dumpin);
             }
 
         // TAXATION !! We could also capture MEC status on other bases here.
diff --git a/ihs_avsolve.cpp b/ihs_avsolve.cpp
index 5a28c92..adee894 100644
--- a/ihs_avsolve.cpp
+++ b/ihs_avsolve.cpp
@@ -70,7 +70,7 @@ class SolveHelper
     double operator()(double a_CandidateValue)
         {
 // CURRENCY !! Consider using zero<currency> instead of double.
-        return av.SolveTest(av.round_minutiae().c(a_CandidateValue)).d();
+        return d(av.SolveTest(av.round_minutiae().c(a_CandidateValue)));
         }
 };
 
@@ -379,11 +379,11 @@ currency AccountValue::Solve
             // Generally, base and term are independent, and it is
             // the base specamt that's being solved for here, so set
             // the minimum as though there were no term.
-            lower_bound = minimum_specified_amount
+            lower_bound = d(minimum_specified_amount
                 (  0 == SolveBeginYear_
                 && yare_input_.EffectiveDate == yare_input_.InforceAsOfDate
                 ,false
-                ).d();
+                ));
             }
             break;
         case mce_solve_ee_prem:
diff --git a/ihs_basicval.cpp b/ihs_basicval.cpp
index ae8bb7c..13cdc93 100644
--- a/ihs_basicval.cpp
+++ b/ihs_basicval.cpp
@@ -1034,8 +1034,8 @@ currency BasicValues::GetModalPremGLP
     // for GPT reimplementation.
     double z = Irc7702_->CalculateGLP
         (a_duration
-        ,a_bft_amt.d()
-        ,a_specamt.d()
+        ,d(a_bft_amt)
+        ,d(a_specamt)
         ,Irc7702_->GetLeastBftAmtEver()
         ,effective_dbopt_7702(DeathBfts_->dbopt()[0], Effective7702DboRop)
         );
@@ -1058,8 +1058,8 @@ currency BasicValues::GetModalPremGSP
 {
     double z = Irc7702_->CalculateGSP
         (a_duration
-        ,a_bft_amt.d()
-        ,a_specamt.d()
+        ,d(a_bft_amt)
+        ,d(a_specamt)
         ,Irc7702_->GetLeastBftAmtEver()
         );
 
@@ -1154,7 +1154,7 @@ std::pair<double,double> BasicValues::approx_mly_ded
     if(yare_input_.AccidentalDeathBenefit)
         {
         double const r = MortalityRates_->AdbRates()[year];
-        mly_ded += r * std::min(specamt.d(), AdbLimit);
+        mly_ded += r * std::min(d(specamt), AdbLimit);
         }
 
     if(yare_input_.SpouseRider)
@@ -1172,12 +1172,12 @@ std::pair<double,double> BasicValues::approx_mly_ded
     if(true) // Written thus for parallelism and to keep 'r' local.
         {
         double const r = Loads_->specified_amount_load(mce_gen_curr)[year];
-        mly_ded += r * std::min(specamt.d(), SpecAmtLoadLimit);
+        mly_ded += r * std::min(d(specamt), SpecAmtLoadLimit);
         }
 
-    mly_ded += Loads_->monthly_policy_fee(mce_gen_curr)[year].d();
+    mly_ded += d(Loads_->monthly_policy_fee(mce_gen_curr)[year]);
 
-    double ann_ded = Loads_->annual_policy_fee(mce_gen_curr)[year].d();
+    double ann_ded = d(Loads_->annual_policy_fee(mce_gen_curr)[year]);
 
     if(yare_input_.WaiverOfPremiumBenefit)
         {
@@ -1186,7 +1186,7 @@ std::pair<double,double> BasicValues::approx_mly_ded
             {
             case oe_waiver_times_specamt:
                 {
-                mly_ded += r * std::min(specamt.d(), WpLimit);
+                mly_ded += r * std::min(d(specamt), WpLimit);
                 }
                 break;
             case oe_waiver_times_deductions:
@@ -1244,7 +1244,7 @@ std::pair<double,double> BasicValues::approx_mly_ded_ex
     if(yare_input_.AccidentalDeathBenefit)
         {
         double const r = MortalityRates_->AdbRates()[year];
-        er_ded += r * std::min(specamt.d(), AdbLimit);
+        er_ded += r * std::min(d(specamt), AdbLimit);
         }
 
     // Paid by ee.
@@ -1265,11 +1265,11 @@ std::pair<double,double> BasicValues::approx_mly_ded_ex
     if(true) // Written thus for parallelism and to keep 'r' local.
         {
         double const r = Loads_->specified_amount_load(mce_gen_curr)[year];
-        er_ded += r * std::min(specamt.d(), SpecAmtLoadLimit);
+        er_ded += r * std::min(d(specamt), SpecAmtLoadLimit);
         }
 
     // Paid by er.
-    er_ded += Loads_->monthly_policy_fee(mce_gen_curr)[year].d();
+    er_ded += d(Loads_->monthly_policy_fee(mce_gen_curr)[year]);
 
     if(yare_input_.WaiverOfPremiumBenefit)
         {
@@ -1279,7 +1279,7 @@ std::pair<double,double> BasicValues::approx_mly_ded_ex
             case oe_waiver_times_specamt:
                 {
                 // Paid by er. (In this case, WP excludes term.)
-                er_ded += r * std::min(specamt.d(), WpLimit);
+                er_ded += r * std::min(d(specamt), WpLimit);
                 }
                 break;
             case oe_waiver_times_deductions:
@@ -1575,11 +1575,11 @@ std::vector<double> const& 
BasicValues::GetBandedCoiRates
 {
     if(UseUnusualCOIBanding && mce_gen_guar != rate_basis)
         {
-        if(CurrCoiTable0Limit <= a_specamt.d() && a_specamt.d() < 
CurrCoiTable1Limit)
+        if(CurrCoiTable0Limit <= d(a_specamt) && d(a_specamt) < 
CurrCoiTable1Limit)
             {
             return MortalityRates_->MonthlyCoiRatesBand1(rate_basis);
             }
-        else if(CurrCoiTable1Limit <= a_specamt.d())
+        else if(CurrCoiTable1Limit <= d(a_specamt))
             {
             return MortalityRates_->MonthlyCoiRatesBand2(rate_basis);
             }
diff --git a/ledger_invariant_init.cpp b/ledger_invariant_init.cpp
index 79a08d1..fc13377 100644
--- a/ledger_invariant_init.cpp
+++ b/ledger_invariant_init.cpp
@@ -147,7 +147,7 @@ void LedgerInvariant::Init(BasicValues const* b)
     // Scalable scalars.
 
     // SOMEDAY !! Things indexed with '[0]' should probably use inforce year 
instead.
-    InitBaseSpecAmt            = (b->DeathBfts_->specamt()[0]).d();
+    InitBaseSpecAmt            = d(b->DeathBfts_->specamt()[0]);
     InitTermSpecAmt            = TermSpecAmt[0];
     ChildRiderAmount           = b->yare_input_.ChildRiderAmount;
     SpouseRiderAmount          = b->yare_input_.SpouseRiderAmount;
@@ -738,7 +738,7 @@ void LedgerInvariant::ReInit(BasicValues const* b)
         }
     SpecAmt                    = doubleize(b->DeathBfts_->specamt());
 
-    InitBaseSpecAmt            = (b->DeathBfts_->specamt()[0]).d();
+    InitBaseSpecAmt            = d(b->DeathBfts_->specamt()[0]);
     InitTermSpecAmt            = TermSpecAmt[0];
 
     IsMec                      = false;
diff --git a/ledger_variant_init.cpp b/ledger_variant_init.cpp
index ffa5c88..55bc3ab 100644
--- a/ledger_variant_init.cpp
+++ b/ledger_variant_init.cpp
@@ -112,7 +112,7 @@ void LedgerVariant::Init
         ;
 
     InitTgtPremHiLoadRate = 
bv.Loads_->target_premium_load_maximum_premium_tax()[bv.yare_input_.InforceYear];
-    InitMlyPolFee         = bv.Loads_->monthly_policy_fee(GenBasis_)           
 [bv.yare_input_.InforceYear].d();
+    InitMlyPolFee         = d(bv.Loads_->monthly_policy_fee(GenBasis_)         
   [bv.yare_input_.InforceYear]);
 
     FullyInitialized = true;
 }
diff --git a/round_to_test.cpp b/round_to_test.cpp
index d3d6113..a21f4be 100644
--- a/round_to_test.cpp
+++ b/round_to_test.cpp
@@ -579,7 +579,7 @@ void round_to_test::test_fundamentals()
 
     // Test rounding double to currency.
     currency c = round0.c(1.61803398875);
-    BOOST_TEST((1.62 - c.d()) < 1e-14);
+    BOOST_TEST((1.62 - d(c)) < 1e-14);
     BOOST_TEST_EQUAL(162, c.cents());
 //  c *= 0.61803398875;
 //  BOOST_TEST_EQUAL(1, c);
diff --git a/solve.cpp b/solve.cpp
index e76f1d3..5be0d24 100644
--- a/solve.cpp
+++ b/solve.cpp
@@ -162,7 +162,7 @@ inline static double SolveSpecAmt(double CandidateValue)
 {
 // IHS !! Change surrchg when SA changes?
     That->SolveSetSpecAmt(round_to_cents.c(CandidateValue), ThatSolveBegYear, 
ThatSolveEndYear);
-    return only_set_values ? 0.0 : SolveTest().d();
+    return only_set_values ? 0.0 : d(SolveTest());
 }
 
 //============================================================================
@@ -170,7 +170,7 @@ inline static double SolvePrem(double CandidateValue)
 //inline static double SolvePrem(currency CandidateValue)
 {
     That->SolveSetPmts(round_to_cents.c(CandidateValue), ThatSolveBegYear, 
ThatSolveEndYear);
-    return only_set_values ? 0.0 : SolveTest().d();
+    return only_set_values ? 0.0 : d(SolveTest());
 }
 
 //============================================================================
@@ -178,7 +178,7 @@ inline static double SolveLoan(double CandidateValue)
 //inline static double SolveLoan(currency CandidateValue)
 {
     That->SolveSetLoans(round_to_cents.c(CandidateValue), ThatSolveBegYear, 
ThatSolveEndYear);
-    return only_set_values ? 0.0 : SolveTest().d();
+    return only_set_values ? 0.0 : d(SolveTest());
 }
 
 //============================================================================
@@ -186,7 +186,7 @@ inline static double SolveWD(double CandidateValue)
 //inline static double SolveWD(currency CandidateValue)
 {
     That->SolveSetWDs(round_to_cents.c(CandidateValue), ThatSolveBegYear, 
ThatSolveEndYear);
-    return only_set_values ? 0.0 : SolveTest().d();
+    return only_set_values ? 0.0 : d(SolveTest());
 }
 
 //============================================================================
@@ -290,7 +290,7 @@ currency AccountValue::Solve()
             LowerBound = 0.0;
             // If solved premium exceeds specified amount, there's a problem.
             // IHS !! Better to use the maximum SA, not the first SA?
-            UpperBound = DeathBfts_->specamt()[0].d();
+            UpperBound = d(DeathBfts_->specamt()[0]);
             Decimals   = 2;
             SolveFn    = SolvePrem;
             }
@@ -360,6 +360,6 @@ currency AccountValue::Solve()
     only_set_values = !Solving;
     currency const solution_cents = round_to_cents.c(Solution.first);
 
-    SolveFn(solution_cents.d());
+    SolveFn(d(solution_cents));
     return solution_cents;
 }



reply via email to

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