[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/004 be42a58 03/11: Assert rather than assign
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/004 be42a58 03/11: Assert rather than assign |
Date: |
Sun, 20 Dec 2020 17:40:09 -0500 (EST) |
branch: valyuta/004
commit be42a586e2c8a1504ae9abc00f65c86c565e713b
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Assert rather than assign
When decimal_root() determines that no root is bracketed, it returns
zero as the "root". Therefore, assigning zero to the answer in that
case is unnecessary. Still, asserting that it's zero does no harm, and
guards against the possibility of future changes that would violate this
undocumented postcondition.
---
ihs_avsolve.cpp | 2 +-
solve.cpp | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ihs_avsolve.cpp b/ihs_avsolve.cpp
index f9b8928..b308bfd 100644
--- a/ihs_avsolve.cpp
+++ b/ihs_avsolve.cpp
@@ -438,7 +438,7 @@ currency AccountValue::Solve
if(root_not_bracketed == solution.second)
{
- solution.first = 0.0;
+ LMI_ASSERT(0.0 == solution.first);
// Don't want this firing continually in census runs.
if(!SolvingForGuarPremium)
{
diff --git a/solve.cpp b/solve.cpp
index 3087d3d..ef64d9b 100644
--- a/solve.cpp
+++ b/solve.cpp
@@ -24,6 +24,7 @@
#include "account_value.hpp"
#include "alert.hpp"
+#include "assert_lmi.hpp"
#include "death_benefits.hpp"
#include "ledger_invariant.hpp"
#include "ledger_variant.hpp"
@@ -332,7 +333,7 @@ currency AccountValue::Solve()
);
if(root_not_bracketed == Solution.second)
{
- Solution.first = 0.0;
+ LMI_ASSERT(0.0 == Solution.first);
warning() << "Solution not found. Using zero instead." << LMI_FLUSH;
}
- [lmi-commits] [lmi] valyuta/004 updated (3742c54 -> b73e751), Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 be42a58 03/11: Assert rather than assign,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/004 4a58266 09/11: Suppress the costly assertion that was recently added, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 2913536 06/11: Fix a unit test, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 c5f666f 08/11: Improve rounding to cents for solves, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 34326d6 04/11: Eliminate a return code that was always zero, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 abb1363 05/11: Refactor a unit test, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 7eacf2b 07/11: Prefer explicit to implicit currency rounding in unit test, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 58962eb 01/11: Refactor, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 9a03ce9 10/11: Add a handy git command, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 b73e751 11/11: Record timings as of 20201215T2247Z SHA1 3742c540, Greg Chicares, 2020/12/20
- [lmi-commits] [lmi] valyuta/004 0c93fc2 02/11: Fix a problem somewhat mystically, Greg Chicares, 2020/12/20