lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 557ac6e 3/8: Assert rather than assign


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 557ac6e 3/8: Assert rather than assign
Date: Tue, 26 Jan 2021 08:12:30 -0500 (EST)

branch: master
commit 557ac6ee7830a81caf2386e16975417ea38ac075
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 b508b89..3fb7c03 100644
--- a/ihs_avsolve.cpp
+++ b/ihs_avsolve.cpp
@@ -435,7 +435,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 d65892d..89023b6 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"
@@ -327,7 +328,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;
         }
 



reply via email to

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