lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] valyuta/002 4a6bc6c 02/14: Resolve confusion


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/002 4a6bc6c 02/14: Resolve confusion
Date: Thu, 17 Sep 2020 16:27:14 -0400 (EDT)

branch: valyuta/002
commit 4a6bc6c3c6aa1059861cdcde7a73a743f5d99131
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Resolve confusion
    
    Perhaps the comment isn't strictly true:
      std::max(X, -std::numeric_limits<double>::max())
    is intended to equal X, but that may not hold for exotic IEEE754 values.
    It seems that is should be true for denormals, but not for negative
    infinity; and it can't be true for NaN. Such matters need not be fretted
    over on this experimental branch today.
---
 ihs_acctval.cpp | 13 ++++++-------
 ihs_avmly.cpp   | 13 ++++++-------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/ihs_acctval.cpp b/ihs_acctval.cpp
index fc92a37..e4c48e7 100644
--- a/ihs_acctval.cpp
+++ b/ihs_acctval.cpp
@@ -611,13 +611,12 @@ void AccountValue::SetInitialValues()
     DcvWpCharge                 = 0.0;
 
     HoneymoonActive             = false;
-    // -2147483647 is
-    //   -std::numeric_limits<int>::max())
-    // The apparent intention was to choose an implausibly large
-    // negative number that can be negated without the sort of
-    // surprising result seen with INT_MIN, which is -2147483648.
-    // Why that intention makes sense is another matter.
-    HoneymoonValue              = currency(-9223372036854775807);
+    // In 'master', this is
+    //   -std::numeric_limits<double>::max()
+    // which is the identity element for std::max(). Here, it's nearly
+    // the equivalent for currency::data_type; dividing it by 101 is a
+    // casual defense against commuting between dollars and cents.
+    HoneymoonValue = currency(-std::numeric_limits<currency::data_type>::max() 
/ 101, true);
     if(mce_gen_curr == GenBasis_)
         {
         HoneymoonActive = yare_input_.HoneymoonEndorsement;
diff --git a/ihs_avmly.cpp b/ihs_avmly.cpp
index fe8c0c5..f0860b7 100644
--- a/ihs_avmly.cpp
+++ b/ihs_avmly.cpp
@@ -2057,13 +2057,12 @@ void AccountValue::TxTestHoneymoonForExpiration()
     if(HoneymoonValue <= currency() || HoneymoonValue < csv_ignoring_loan)
         {
         HoneymoonActive = false;
-        // -2147483647 is
-        //   -std::numeric_limits<int>::max())
-        // The apparent intention was to choose an implausibly large
-        // negative number that can be negated without the sort of
-        // surprising result seen with INT_MIN, which is -2147483648.
-        // Why that intention makes sense is another matter.
-        HoneymoonValue  = currency(-9223372036854775807);
+        // In 'master', this is
+        //   -std::numeric_limits<double>::max()
+        // which is the identity element for std::max(). Here, it's nearly
+        // the equivalent for currency::data_type; dividing it by 101 is a
+        // casual defense against commuting between dollars and cents.
+        HoneymoonValue  = 
currency(-std::numeric_limits<currency::data_type>::max() / 101, true);
         }
 }
 



reply via email to

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