[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 8f97c07 2/4: Dispel latent confusion
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 8f97c07 2/4: Dispel latent confusion |
Date: |
Fri, 2 Nov 2018 07:42:53 -0400 (EDT) |
branch: master
commit 8f97c07f615a80d1a767413222a63aaf50ee77d3
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>
Dispel latent confusion
A negative account value clearly mustn't induce a negative corridor.
The original code wasn't actually incorrect, because std::max()
wouldn't choose its second argument if it were negative (as long
as its first argument is never negative, as is now asserted):
DBReflectingCorr = std::max
(DBIgnoringCorr
- ,YearsCorridorFactor * cash_value_for_corridor
+ ,YearsCorridorFactor * std::max(0.0, cash_value_for_corridor)
);
but no good can come from allowing the second argument to be negative
when that's obviously contrary to Congressional intent.
---
ihs_avmly.cpp | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index eb2171d..d9bee90 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -1616,6 +1616,7 @@ void AccountValue::TxSetDeathBft()
}
break;
}
+ LMI_ASSERT(0.0 <= DBIgnoringCorr);
// Surrender charges are generally ignored here, but any negative
// surrender charge must be subtracted, increasing the account value.
@@ -1633,9 +1634,10 @@ void AccountValue::TxSetDeathBft()
DBReflectingCorr = std::max
(DBIgnoringCorr
- ,YearsCorridorFactor * cash_value_for_corridor
+ ,YearsCorridorFactor * std::max(0.0, cash_value_for_corridor)
);
DBReflectingCorr = round_death_benefit()(DBReflectingCorr);
+ LMI_ASSERT(0.0 <= DBReflectingCorr);
// This overrides the value assigned above. There's more than one
// way to interpret 7702A "death benefit"; this is just one.
// TAXATION !! Use DB_Irc7702BftIsSpecAmt