[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>
- [lmi-commits] [lmi] branch valyuta/005 created (now 4401725), Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 fd74b61 03/17: Correct an obvious mistake, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 7d6e748 02/17: Improve currency class and unit tests, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 4902da4 01/17: Reinvent currency ab ovo, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 ffa2ce4 09/17: Redesign unit test, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 90d7483 10/17: Improve currency class, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 3d44f42 13/17: Save a sorted list of regressions, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 c8864d3 04/17: Add commented-out relops, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 f3219f8 12/17: Use CURRENCY_UNIT_IS_CENTS appropriately,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/005 aad51dd 07/17: Inline more, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 b852a68 05/17: Add features, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 d69f05c 06/17: Ratify some regression-testing differences, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 2aae91a 14/17: Improve incrementally, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 0735250 15/17: Improve incrementally, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 dfdbf3c 16/17: Use currency type for class members as appropriate, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 221c094 08/17: Prefer constexpr, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 4401725 17/17: Merge branch 'master' into valyuta/005, Greg Chicares, 2021/01/16
- [lmi-commits] [lmi] valyuta/005 e3f3eff 11/17: Revert "Ratify some regression-testing differences", Greg Chicares, 2021/01/16