lmi-commits
[Top][All Lists]
Advanced

[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;
         }
 



reply via email to

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