[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] valyuta/002 e9f5447 30/65: round currency to currenc
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] valyuta/002 e9f5447 30/65: round currency to currency? huh? |
Date: |
Wed, 16 Sep 2020 16:55:16 -0400 (EDT) |
branch: valyuta/002
commit e9f5447ba46a4620be3d71ec2495162cbf17ec45
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
round currency to currency? huh?
---
round_to.hpp | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/round_to.hpp b/round_to.hpp
index 0fb1779..629d12a 100644
--- a/round_to.hpp
+++ b/round_to.hpp
@@ -271,6 +271,10 @@ class round_to
currency c(RealType r) const;
std::vector<currency> c(std::vector<RealType> r) const;
+ currency c(currency z) const;
+// is this wanted?
+// std::vector<currency> c(std::vector<RealType> r) const;
+
int decimals() const;
rounding_style style() const;
@@ -416,6 +420,14 @@ 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
+ // instead, this ought to verify proper rounding
+ return z;
+}
+
+template<typename RealType>
int round_to<RealType>::decimals() const
{
return decimals_;
- [lmi-commits] [lmi] valyuta/002 7481c2b 09/65: discard--throwaway assertions, (continued)
- [lmi-commits] [lmi] valyuta/002 7481c2b 09/65: discard--throwaway assertions, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 998fdf5 35/65: operator/(), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 c105c78 29/65: Currency: implement binary operator-, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 9cf4517 46/65: c(), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 9da6616 55/65: Round explicitly in a few more cases, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 0e8c429 12/65: rounding, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 794727e 22/65: Round when converting from double to currency, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 d137177 02/65: Currency, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 ba6a8d1 31/65: implement currency comparisons as free functions, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 28a5e54 39/65: make data_type public, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 e9f5447 30/65: round currency to currency? huh?,
Greg Chicares <=
- [lmi-commits] [lmi] valyuta/002 90773f3 47/65: currency() rather than currency(0.0), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 5f00c5a 43/65: Add a commented-out idea, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 2dabfcf 62/65: Try to make something a little less arcane, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 9433c8e 65/65: Discuss timing, and philosophical and political questions, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 9bee994 19/65: use currency type, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 0bf83a4 18/65: augment, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 615a24c 48/65: round.c(), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 9a4b91d 51/65: Speed measurements, Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 49f84a1 60/65: Don't convert type with operator=(), Greg Chicares, 2020/09/16
- [lmi-commits] [lmi] valyuta/002 9a9665c 58/65: Record some speed improvements, Greg Chicares, 2020/09/16