[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [lmi] master 99b465d 3/4: Resolve conversion warnings for
From: |
Greg Chicares |
Subject: |
[lmi-commits] [lmi] master 99b465d 3/4: Resolve conversion warnings for currency class |
Date: |
Thu, 6 Aug 2020 15:52:20 -0400 (EDT) |
branch: master
commit 99b465d54d045febfcba742f36bed3ba52c4705f
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>
Resolve conversion warnings for currency class
---
currency.hpp | 6 ++++--
currency_test.cpp | 5 +++--
workhorse.make | 2 --
3 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/currency.hpp b/currency.hpp
index e1f8864..4f494e6 100644
--- a/currency.hpp
+++ b/currency.hpp
@@ -24,6 +24,8 @@
#include "config.hpp"
+#include "bourn_cast.hpp"
+
#include <cmath>
#include <cstdint>
#include <cstdlib>
@@ -132,7 +134,7 @@ class currency
int cents() const
{
- return cents_ % cents_per_dollar;
+ return bourn_cast<int>(cents_ % cents_per_dollar);
}
/// Total number of cents, e.g., 123 for 1 dollar and 23 cents.
@@ -146,7 +148,7 @@ class currency
double value() const
{
- double result = cents_;
+ double result = bourn_cast<double>(cents_);
result /= cents_per_dollar;
return result;
}
diff --git a/currency_test.cpp b/currency_test.cpp
index 189a50b..d18ca44 100644
--- a/currency_test.cpp
+++ b/currency_test.cpp
@@ -23,6 +23,7 @@
#include "currency.hpp"
+#include "bourn_cast.hpp"
#include "materially_equal.hpp"
#include "miscellany.hpp" // stifle_warning_for_unused_value()
#include "test_tools.hpp"
@@ -226,7 +227,7 @@ currency currency_test::arbitrary_amount<currency>()
template<typename T>
inline double convert_to_double(T t)
{
- return t;
+ return bourn_cast<double>(t);
}
template<>
@@ -238,7 +239,7 @@ inline double convert_to_double(currency c)
template<typename T>
inline T convert_from_double(double d)
{
- return d;
+ return bourn_cast<T>(d);
}
template<>
diff --git a/workhorse.make b/workhorse.make
index 6dea4f4..3448bc8 100644
--- a/workhorse.make
+++ b/workhorse.make
@@ -613,12 +613,10 @@ $(xmlwrapp_objects): gcc_common_extra_warnings += \
# SOMEDAY !! Address some of these '-Wconversion' issues.
wno_conv_objects := \
- currency_test.o \
rate_table.o \
round_glibc.o \
$(wno_conv_objects): gcc_common_extra_warnings += -Wno-conversion
-Wfloat-conversion
-currency_test.o: gcc_common_extra_warnings += -Wno-float-conversion
wno_sign_conv_objects := \
$(boost_dependent_objects) \