lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] valyuta/002 1700262 1/8: Make fewer costly assertion


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/002 1700262 1/8: Make fewer costly assertions
Date: Mon, 5 Oct 2020 19:57:18 -0400 (EDT)

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

    Make fewer costly assertions
    
    See commit 71925816be4 of 20201004T1559Z.
---
 round_to.hpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/round_to.hpp b/round_to.hpp
index dade585..9ca6597 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -389,11 +389,16 @@ inline currency round_to<RealType>::c(RealType r) const
     // ROUNDING move this restriction to rounding_rules
     // enabling it here imposes a three-percent overhead
 //  LMI_ASSERT(decimals() <= 2);
-    if(std::numeric_limits<currency::data_type>::is_integer)
+#if defined CURRENCY_HAS_INTEGER_DATATYPE
+// This conditional didn't have zero overhead with 'double';
+// perhaps 'if constexpr' would have worked, but the preprocessor
+// certainly does:
+//  if(std::numeric_limits<currency::data_type>::is_integer)
         {
         // Precondition for casting to integer below:
         LMI_ASSERT(decimals() <= currency::cents_digits);
         }
+#endif // defined CURRENCY_HAS_INTEGER_DATATYPE
     RealType z = static_cast<RealType>
         (rounding_function_(static_cast<RealType>(r * scale_fwd_)) * 
scale_back_c_
         );
@@ -429,7 +434,7 @@ inline std::vector<currency> 
round_to<RealType>::c(std::vector<RealType> r) cons
 template<typename RealType>
 inline currency round_to<RealType>::c(currency z) const
 {
-    LMI_ASSERT(decimals() <= 2); // ROUNDING similarly restrict rounding_rules
+//  LMI_ASSERT(decimals() <= 2); // ROUNDING similarly restrict rounding_rules
     // instead, this ought to verify proper rounding
     return z;
 }



reply via email to

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