lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] valyuta/005 f3219f8 12/17: Use CURRENCY_UNIT_IS_CENT


From: Greg Chicares
Subject: [lmi-commits] [lmi] valyuta/005 f3219f8 12/17: Use CURRENCY_UNIT_IS_CENTS appropriately
Date: Sat, 16 Jan 2021 21:06:18 -0500 (EST)

branch: valyuta/005
commit f3219f89b53f626ce0d8a2ef3c47840c433a1edc
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    Use CURRENCY_UNIT_IS_CENTS appropriately
    
    At least for the time being, it's useful to be able to build both with
    and without this macro defined.
---
 currency.hpp |  6 +++---
 round_to.hpp | 10 +++++-----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/currency.hpp b/currency.hpp
index db76089..917fd66 100644
--- a/currency.hpp
+++ b/currency.hpp
@@ -39,13 +39,13 @@ class LMI_SO currency
     friend class currency_test;
     template<typename T> friend class round_to;
     friend class round_to_test;
-#if 1
+#if defined CURRENCY_UNIT_IS_CENTS
     static constexpr int    cents_digits     = 2;
     static constexpr double cents_per_dollar = 100.0;
-#else
+#else  // !defined CURRENCY_UNIT_IS_CENTS
     static constexpr int    cents_digits     = 0;
     static constexpr double cents_per_dollar = 1.0;
-#endif // 1
+#endif // !defined CURRENCY_UNIT_IS_CENTS
 
   public:
     using data_type = double;
diff --git a/round_to.hpp b/round_to.hpp
index ddb0bef..3788a5b 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -404,11 +404,11 @@ 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
 {
-    return
-        (decimals_ < currency::cents_digits)
-        ? c(z.d())
-        : z
-        ;
+#if defined CURRENCY_UNIT_IS_CENTS
+    return (decimals_ < currency::cents_digits) ? c(z.d()) : z;
+#else  // !defined CURRENCY_UNIT_IS_CENTS
+    return c(z.d());
+#endif // !defined CURRENCY_UNIT_IS_CENTS
 }
 
 template<typename RealType>



reply via email to

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