[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;
}
- [lmi-commits] [lmi] master updated (15ef269 -> 7066049), Greg Chicares, 2021/01/26
- [lmi-commits] [lmi] master 557ac6e 3/8: Assert rather than assign,
Greg Chicares <=
- [lmi-commits] [lmi] master 026214c 4/8: Solve for currency rather than double, Greg Chicares, 2021/01/26
- [lmi-commits] [lmi] master 62b80c4 7/8: Initialize honeymoon value as currency, not double, Greg Chicares, 2021/01/26
- [lmi-commits] [lmi] master 0b4b7ec 1/8: Don't use currency for amounts always converted to double, Greg Chicares, 2021/01/26
- [lmi-commits] [lmi] master 01886b2 5/8: Round CSV "boost", Greg Chicares, 2021/01/26
- [lmi-commits] [lmi] master e507882 6/8: Remove a useless assertion, Greg Chicares, 2021/01/26
- [lmi-commits] [lmi] master 7066049 8/8: Record speed measurements, Greg Chicares, 2021/01/26
- [lmi-commits] [lmi] master e7ab330 2/8: Store currency as such, Greg Chicares, 2021/01/26