lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] odd/eraseme 773ad30 3/4: Use the correct identity el


From: Greg Chicares
Subject: [lmi-commits] [lmi] odd/eraseme 773ad30 3/4: Use the correct identity element for std::max<currency, currency>
Date: Fri, 5 Mar 2021 14:08:07 -0500 (EST)

branch: odd/eraseme
commit 773ad309a5111f5d46df7f31a307c1db8c9c1fad
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Use the correct identity element for std::max<currency,currency>
    
    The currency class is implemented in terms of type double, and the
    identity element for std::max<double,double> is infinity (provided
    that infinity is supported, which is required by IEEE754).
---
 ihs_acctval.cpp | 7 +++----
 ihs_avmly.cpp   | 6 +++---
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index c6f1e97..dfd4e3c 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -31,6 +31,7 @@
 #include "dbnames.hpp"
 #include "death_benefits.hpp"
 #include "i7702.hpp"
+#include "ieee754.hpp"                  // infinity<>()
 #include "ihs_irc7702.hpp"
 #include "ihs_irc7702a.hpp"
 #include "input.hpp"                    // consummate()
@@ -53,7 +54,6 @@
 #include <iomanip>                      // setprecision()
 #include <ios>                          // ios_base::fixed()
 #include <iterator>                     // back_inserter()
-#include <limits>
 #include <numeric>
 #include <string>
 #include <utility>
@@ -632,9 +632,8 @@ void AccountValue::SetInitialValues()
     DcvWpCharge                 = C0;
 
     HoneymoonActive             = false;
-    // Identity element for std::max(), disregarding -INF and NaN.
-    // CURRENCY !! alternatively, use -INF
-    HoneymoonValue = 
-from_cents(std::numeric_limits<currency::data_type>::max());
+    // Identity element for std::max().
+    HoneymoonValue = -from_cents(infinity<double>());
     if(mce_gen_curr == GenBasis_)
         {
         HoneymoonActive = yare_input_.HoneymoonEndorsement;
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index cd94fd6..b391970 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -29,6 +29,7 @@
 #include "database.hpp"
 #include "dbnames.hpp"
 #include "death_benefits.hpp"
+#include "ieee754.hpp"                  // infinity<>()
 #include "ihs_irc7702.hpp"
 #include "ihs_irc7702a.hpp"
 #include "interest_rates.hpp"
@@ -46,7 +47,6 @@
 
 #include <algorithm>                    // min(), max()
 #include <cmath>                        // pow()
-#include <limits>
 
 // Each month, process all transactions in order.
 
@@ -1962,8 +1962,8 @@ void AccountValue::TxTestHoneymoonForExpiration()
     if(HoneymoonValue <= C0 || HoneymoonValue < csv_ignoring_loan)
         {
         HoneymoonActive = false;
-        // CURRENCY !! alternatively, use -INF
-        HoneymoonValue = 
-from_cents(std::numeric_limits<currency::data_type>::max());
+        // Identity element for std::max().
+        HoneymoonValue = -from_cents(infinity<double>());
         }
 }
 



reply via email to

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