Removed all dependency on gdtoa.
This commit is contained in:
parent
9400435870
commit
f1257cbc3e
13 changed files with 8 additions and 202 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,6 +1,3 @@
|
|||
[submodule "lib/gdtoa"]
|
||||
path = lib/gdtoa
|
||||
url = git://github.com/jwiegley/gdtoa.git
|
||||
[submodule "lib/cppunit"]
|
||||
path = lib/cppunit
|
||||
url = git://github.com/jwiegley/cppunit.git
|
||||
|
|
|
|||
47
Makefile.am
47
Makefile.am
|
|
@ -1,8 +1,4 @@
|
|||
VERSION = 3.0
|
||||
|
||||
if HAVE_GDTOA
|
||||
SUBDIRS = lib/gdtoa
|
||||
endif
|
||||
VERSION = 3.0
|
||||
EXTRA_DIST = autogen.sh contrib
|
||||
|
||||
lib_LTLIBRARIES = \
|
||||
|
|
@ -17,9 +13,6 @@ lib_LTLIBRARIES = \
|
|||
lib_cppflags = -I$(srcdir)/src -I$(srcdir)/lib \
|
||||
-I$(srcdir)/lib/utfcpp/source \
|
||||
-I$(srcdir)/lib/irrxml/src
|
||||
if HAVE_GDTOA
|
||||
lib_cppflags += -I$(top_builddir)/lib/gdtoa -I$(srcdir)/lib/gdtoa
|
||||
endif
|
||||
if HAVE_LIBOFX
|
||||
lib_cppflags += -DHAVE_LIBOFX=1
|
||||
endif
|
||||
|
|
@ -209,9 +202,6 @@ ledger_CPPFLAGS += -DHAVE_BOOST_PYTHON=1 -I$(srcdir)/python
|
|||
endif
|
||||
ledger_SOURCES = src/main.cc
|
||||
ledger_LDADD = $(LIBOBJS) $(lib_LTLIBRARIES)
|
||||
if HAVE_GDTOA
|
||||
ledger_LDADD += lib/gdtoa/libgdtoa.la
|
||||
endif
|
||||
if HAVE_BOOST_PYTHON
|
||||
ledger_LDADD += libledger_python.la
|
||||
endif
|
||||
|
|
@ -269,22 +259,6 @@ clean-local:
|
|||
uninstall-hook:
|
||||
rm -f $(DESTDIR)$(libdir)/Ledger-$(VERSION)-py$(PYTHON_VERSION).egg-info
|
||||
|
||||
if HAVE_GDTOA
|
||||
install-exec-hook:
|
||||
BUILD_DIR=`cd $(top_builddir); pwd`; \
|
||||
SRC_DIR=`cd $(srcdir); pwd`; \
|
||||
(cd $(srcdir); \
|
||||
CFLAGS="$(CPPFLAGS) -I$(srcdir) -I$$BUILD_DIR -I$$BUILD_DIR/lib/gdtoa $(libledger_python_la_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)" \
|
||||
LDFLAGS="$(LDFLAGS) -L$$BUILD_DIR -L$$BUILD_DIR/.libs -L$$BUILD_DIR/lib/gdtoa -L$$BUILD_DIR/lib/gdtoa/.libs" \
|
||||
ARCHFLAGS="$(ARCHFLAGS)" PYLIBS="$(PYLIBS)" VERSION="$(VERSION)" \
|
||||
SRCDIR="$$SRC_DIR" $(PYTHON) python/setup.py install \
|
||||
--skip-build \
|
||||
--root=$(DESTDIR)/ \
|
||||
--prefix=$(prefix) \
|
||||
--install-lib=$(libdir) \
|
||||
--install-headers=$(pkgincludedir) \
|
||||
--install-data=$(datadir))
|
||||
else
|
||||
install-exec-hook:
|
||||
BUILD_DIR=`cd $(top_builddir); pwd`; \
|
||||
SRC_DIR=`cd $(srcdir); pwd`; \
|
||||
|
|
@ -299,7 +273,6 @@ install-exec-hook:
|
|||
--install-lib=$(libdir) \
|
||||
--install-headers=$(pkgincludedir) \
|
||||
--install-data=$(datadir))
|
||||
endif
|
||||
|
||||
ledger_so_SOURCES = $(all_sources)
|
||||
ledger_so_DEPENDENCIES = $(lib_LTLIBRARIES)
|
||||
|
|
@ -315,24 +288,10 @@ PYLIBS = ledger_util ledger_math ledger_expr \
|
|||
boost_regex$(BOOST_SUFFIX) \
|
||||
boost_python$(BOOST_SUFFIX)
|
||||
|
||||
if HAVE_GDTOA
|
||||
PYLIBS += gdtoa
|
||||
endif
|
||||
if HAVE_LIBOFX
|
||||
PYLIBS += ofx
|
||||
endif
|
||||
|
||||
if HAVE_GDTOA
|
||||
ledger.so: $(ledger_so_SOURCES) $(ledger_so_DEPENDENCIES)
|
||||
BUILD_DIR=`cd $(top_builddir); pwd`; \
|
||||
SRC_DIR=`cd $(srcdir); pwd`; \
|
||||
(cd $(srcdir); \
|
||||
CFLAGS="$(CPPFLAGS) -I$(srcdir) -I$$BUILD_DIR -I$$BUILD_DIR/lib/gdtoa $(libledger_python_la_CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)" \
|
||||
LDFLAGS="$(LDFLAGS) -L$$BUILD_DIR -L$$BUILD_DIR/.libs -L$$BUILD_DIR/lib/gdtoa -L$$BUILD_DIR/lib/gdtoa/.libs" \
|
||||
ARCHFLAGS="$(ARCHFLAGS)" PYLIBS="$(PYLIBS)" VERSION="$(VERSION)" \
|
||||
SRCDIR="$$SRC_DIR" $(PYTHON) python/setup.py build \
|
||||
--build-lib=$$BUILD_DIR/ --build-temp=$$BUILD_DIR/build -f)
|
||||
else
|
||||
ledger.so: $(ledger_so_SOURCES) $(ledger_so_DEPENDENCIES)
|
||||
BUILD_DIR=`cd $(top_builddir); pwd`; \
|
||||
SRC_DIR=`cd $(srcdir); pwd`; \
|
||||
|
|
@ -342,7 +301,6 @@ ledger.so: $(ledger_so_SOURCES) $(ledger_so_DEPENDENCIES)
|
|||
ARCHFLAGS="$(ARCHFLAGS)" PYLIBS="$(PYLIBS)" VERSION="$(VERSION)" \
|
||||
SRCDIR="$$SRC_DIR" $(PYTHON) python/setup.py build \
|
||||
--build-lib=$$BUILD_DIR/ --build-temp=$$BUILD_DIR/build -f)
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
|
|
@ -396,9 +354,6 @@ math_tests_SOURCES = \
|
|||
|
||||
math_tests_CPPFLAGS = -I$(srcdir)/test $(lib_cppflags)
|
||||
math_tests_LDADD = $(util_tests_LDADD) libledger_math.la
|
||||
if HAVE_GDTOA
|
||||
math_tests_LDADD += lib/gdtoa/libgdtoa.la
|
||||
endif
|
||||
|
||||
expr_tests_SOURCES = \
|
||||
test/UnitTests.cc \
|
||||
|
|
|
|||
14
configure.ac
14
configure.ac
|
|
@ -23,20 +23,6 @@ AM_PROG_LIBTOOL
|
|||
AM_PATH_LISPDIR
|
||||
|
||||
# Check for options
|
||||
AC_ARG_ENABLE(gdtoa,
|
||||
[ --disable-gdtoa Do not build with David Gay's gdtoa library],
|
||||
[case "${enableval}" in
|
||||
yes) gdtoa=true ;;
|
||||
no) gdtoa=false ;;
|
||||
*) AC_MSG_ERROR(bad value ${enableval} for --enable-gdtoa) ;;
|
||||
esac],[gdtoa=true])
|
||||
|
||||
if test x$gdtoa = xtrue; then
|
||||
AM_CONDITIONAL(HAVE_GDTOA, true)
|
||||
AC_DEFINE([HAVE_GDTOA], [1], [Whether gdtoa is available])
|
||||
AC_CONFIG_SUBDIRS([lib/gdtoa])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(debug,
|
||||
[ --enable-debug Turn on debugging],
|
||||
[case "${enableval}" in
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 120ed618432939b2f372d3249230e8812c04ddc3
|
||||
|
|
@ -48,14 +48,12 @@ amount_t py_round_1(const amount_t& amount, amount_t::precision_t prec) {
|
|||
return amount.round(prec);
|
||||
}
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
double py_to_double_0(amount_t& amount) {
|
||||
return amount.to_double();
|
||||
}
|
||||
double py_to_double_1(amount_t& amount, bool no_check) {
|
||||
return amount.to_double(no_check);
|
||||
}
|
||||
#endif
|
||||
|
||||
long py_to_long_0(amount_t& amount) {
|
||||
return amount.to_long();
|
||||
|
|
@ -169,9 +167,7 @@ void export_amount()
|
|||
make_getter(&amount_t::stream_fullstrings),
|
||||
make_setter(&amount_t::stream_fullstrings))
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(init<double>())
|
||||
#endif
|
||||
.def(init<long>())
|
||||
.def(init<std::string>())
|
||||
|
||||
|
|
@ -187,108 +183,80 @@ internal precision.")
|
|||
.def(self == self)
|
||||
.def(self == long())
|
||||
.def(long() == self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self == double())
|
||||
.def(double() == self)
|
||||
#endif
|
||||
|
||||
.def(self != self)
|
||||
.def(self != long())
|
||||
.def(long() != self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self != double())
|
||||
.def(double() != self)
|
||||
#endif
|
||||
|
||||
.def(! self)
|
||||
|
||||
.def(self < self)
|
||||
.def(self < long())
|
||||
.def(long() < self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self < double())
|
||||
.def(double() < self)
|
||||
#endif
|
||||
|
||||
.def(self <= self)
|
||||
.def(self <= long())
|
||||
.def(long() <= self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self <= double())
|
||||
.def(double() <= self)
|
||||
#endif
|
||||
|
||||
.def(self > self)
|
||||
.def(self > long())
|
||||
.def(long() > self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self > double())
|
||||
.def(double() > self)
|
||||
#endif
|
||||
|
||||
.def(self >= self)
|
||||
.def(self >= long())
|
||||
.def(long() >= self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self >= double())
|
||||
.def(double() >= self)
|
||||
#endif
|
||||
|
||||
.def(self += self)
|
||||
.def(self += long())
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self += double())
|
||||
#endif
|
||||
|
||||
.def(self + self)
|
||||
.def(self + long())
|
||||
.def(long() + self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self + double())
|
||||
.def(double() + self)
|
||||
#endif
|
||||
|
||||
.def(self -= self)
|
||||
.def(self -= long())
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self -= double())
|
||||
#endif
|
||||
|
||||
.def(self - self)
|
||||
.def(self - long())
|
||||
.def(long() - self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self - double())
|
||||
.def(double() - self)
|
||||
#endif
|
||||
|
||||
.def(self *= self)
|
||||
.def(self *= long())
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self *= double())
|
||||
#endif
|
||||
|
||||
.def(self * self)
|
||||
.def(self * long())
|
||||
.def(long() * self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self * double())
|
||||
.def(double() * self)
|
||||
#endif
|
||||
|
||||
.def(self /= self)
|
||||
.def(self /= long())
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self /= double())
|
||||
#endif
|
||||
|
||||
.def(self / self)
|
||||
.def(self / long())
|
||||
.def(long() / self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self / double())
|
||||
.def(double() / self)
|
||||
#endif
|
||||
|
||||
.def("precision", &amount_t::precision)
|
||||
|
||||
|
|
@ -323,11 +291,9 @@ internal precision.")
|
|||
.def("is_realzero", &amount_t::is_realzero)
|
||||
.def("is_null", &amount_t::is_null)
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
.def("to_double", py_to_double_0)
|
||||
.def("to_double", py_to_double_1)
|
||||
.def("__float__", py_to_double_0)
|
||||
#endif
|
||||
.def("to_long", py_to_long_0)
|
||||
.def("to_long", py_to_long_1)
|
||||
.def("__int__", py_to_long_0)
|
||||
|
|
@ -336,9 +302,7 @@ internal precision.")
|
|||
.def("to_fullstring", &amount_t::to_fullstring)
|
||||
.def("__repr__", &amount_t::to_fullstring)
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
.def("fits_in_double", &amount_t::fits_in_double)
|
||||
#endif
|
||||
.def("fits_in_long", &amount_t::fits_in_long)
|
||||
|
||||
.def("quantity_string", &amount_t::quantity_string)
|
||||
|
|
@ -391,9 +355,7 @@ internal precision.")
|
|||
|
||||
register_optional_to_python<amount_t>();
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
implicitly_convertible<double, amount_t>();
|
||||
#endif
|
||||
implicitly_convertible<long, amount_t>();
|
||||
implicitly_convertible<string, amount_t>();
|
||||
|
||||
|
|
|
|||
|
|
@ -89,9 +89,7 @@ void export_value()
|
|||
.staticmethod("shutdown")
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(init<double>())
|
||||
#endif
|
||||
.def(init<long>())
|
||||
.def(init<std::string>())
|
||||
.def(init<date_t>())
|
||||
|
|
@ -111,108 +109,80 @@ void export_value()
|
|||
.def(self == self)
|
||||
.def(self == long())
|
||||
.def(long() == self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self == double())
|
||||
.def(double() == self)
|
||||
#endif
|
||||
|
||||
.def(self != self)
|
||||
.def(self != long())
|
||||
.def(long() != self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self != double())
|
||||
.def(double() != self)
|
||||
#endif
|
||||
|
||||
.def(! self)
|
||||
|
||||
.def(self < self)
|
||||
.def(self < long())
|
||||
.def(long() < self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self < double())
|
||||
.def(double() < self)
|
||||
#endif
|
||||
|
||||
.def(self <= self)
|
||||
.def(self <= long())
|
||||
.def(long() <= self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self <= double())
|
||||
.def(double() <= self)
|
||||
#endif
|
||||
|
||||
.def(self > self)
|
||||
.def(self > long())
|
||||
.def(long() > self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self > double())
|
||||
.def(double() > self)
|
||||
#endif
|
||||
|
||||
.def(self >= self)
|
||||
.def(self >= long())
|
||||
.def(long() >= self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self >= double())
|
||||
.def(double() >= self)
|
||||
#endif
|
||||
|
||||
.def(self += self)
|
||||
.def(self += long())
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self += double())
|
||||
#endif
|
||||
|
||||
.def(self + self)
|
||||
.def(self + long())
|
||||
.def(long() + self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self + double())
|
||||
.def(double() + self)
|
||||
#endif
|
||||
|
||||
.def(self -= self)
|
||||
.def(self -= long())
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self -= double())
|
||||
#endif
|
||||
|
||||
.def(self - self)
|
||||
.def(self - long())
|
||||
.def(long() - self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self - double())
|
||||
.def(double() - self)
|
||||
#endif
|
||||
|
||||
.def(self *= self)
|
||||
.def(self *= long())
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self *= double())
|
||||
#endif
|
||||
|
||||
.def(self * self)
|
||||
.def(self * long())
|
||||
.def(long() * self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self * double())
|
||||
.def(double() * self)
|
||||
#endif
|
||||
|
||||
.def(self /= self)
|
||||
.def(self /= long())
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self /= double())
|
||||
#endif
|
||||
|
||||
.def(self / self)
|
||||
.def(self / long())
|
||||
.def(long() / self)
|
||||
#ifdef HAVE_GDTOA
|
||||
.def(self / double())
|
||||
.def(double() / self)
|
||||
#endif
|
||||
|
||||
.def("add", &value_t::add,
|
||||
return_value_policy<reference_existing_object>())
|
||||
|
|
@ -336,9 +306,7 @@ void export_value()
|
|||
|
||||
register_optional_to_python<value_t>();
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
implicitly_convertible<double, value_t>();
|
||||
#endif
|
||||
implicitly_convertible<long, value_t>();
|
||||
implicitly_convertible<string, value_t>();
|
||||
implicitly_convertible<date_t, value_t>();
|
||||
|
|
|
|||
|
|
@ -223,8 +223,6 @@ void amount_t::_release()
|
|||
}
|
||||
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
|
||||
namespace {
|
||||
amount_t::precision_t convert_double(mpz_t dest, double val)
|
||||
{
|
||||
|
|
@ -277,8 +275,6 @@ amount_t::amount_t(const double val) : commodity_(NULL)
|
|||
quantity->prec = convert_double(MPZ(quantity), val);
|
||||
}
|
||||
|
||||
#endif // HAVE_GDTOA
|
||||
|
||||
amount_t::amount_t(const unsigned long val) : commodity_(NULL)
|
||||
{
|
||||
TRACE_CTOR(amount_t, "const unsigned long");
|
||||
|
|
@ -683,8 +679,6 @@ bool amount_t::is_zero() const
|
|||
}
|
||||
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
|
||||
double amount_t::to_double(bool no_check) const
|
||||
{
|
||||
if (! quantity)
|
||||
|
|
@ -716,8 +710,6 @@ double amount_t::to_double(bool no_check) const
|
|||
return value;
|
||||
}
|
||||
|
||||
#endif // HAVE_GDTOA
|
||||
|
||||
long amount_t::to_long(bool no_check) const
|
||||
{
|
||||
if (! quantity)
|
||||
|
|
@ -735,16 +727,12 @@ long amount_t::to_long(bool no_check) const
|
|||
return value;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
|
||||
bool amount_t::fits_in_double() const
|
||||
{
|
||||
double value = to_double(true);
|
||||
return *this == amount_t(value);
|
||||
}
|
||||
|
||||
#endif // HAVE_GDTOA
|
||||
|
||||
bool amount_t::fits_in_long() const
|
||||
{
|
||||
long value = to_long(true);
|
||||
|
|
|
|||
24
src/amount.h
24
src/amount.h
|
|
@ -49,11 +49,6 @@
|
|||
* division or multiplication is performed, the precision is
|
||||
* automatically expanded to include as many extra digits as necessary
|
||||
* to avoid losing information.
|
||||
*
|
||||
* Floating-point math is never used at any point in these routines. If
|
||||
* floating-point numbers are used to create amounts, they are first
|
||||
* rendered to decimal using David Gay's gdtoa library, and then parsed
|
||||
* as multi-precision values.
|
||||
*/
|
||||
#ifndef _AMOUNT_H
|
||||
#define _AMOUNT_H
|
||||
|
|
@ -80,14 +75,9 @@ DECLARE_EXCEPTION(amount_error, std::runtime_error);
|
|||
*/
|
||||
class amount_t
|
||||
: public ordered_field_operators<amount_t,
|
||||
#ifdef HAVE_GDTOA
|
||||
ordered_field_operators<amount_t, double,
|
||||
#endif
|
||||
ordered_field_operators<amount_t, unsigned long,
|
||||
ordered_field_operators<amount_t, long> > >
|
||||
#ifdef HAVE_GDTOA
|
||||
>
|
||||
#endif
|
||||
ordered_field_operators<amount_t, long> > > >
|
||||
{
|
||||
public:
|
||||
/** Ready the amount subsystem for use.
|
||||
|
|
@ -172,11 +162,9 @@ public:
|
|||
TRACE_CTOR(amount_t, "");
|
||||
}
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
/** Convert a double to an amount. As much precision as possible is
|
||||
decoded from the binary floating point number. */
|
||||
amount_t(const double val);
|
||||
#endif
|
||||
|
||||
/** Convert an unsigned long to an amount. It's precision is zero. */
|
||||
amount_t(const unsigned long val);
|
||||
|
|
@ -251,11 +239,9 @@ public:
|
|||
be freed. */
|
||||
amount_t& operator=(const amount_t& amt);
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
amount_t& operator=(const double val) {
|
||||
return *this = amount_t(val);
|
||||
}
|
||||
#endif
|
||||
amount_t& operator=(const unsigned long val) {
|
||||
return *this = amount_t(val);
|
||||
}
|
||||
|
|
@ -506,18 +492,14 @@ public:
|
|||
been stripped and the full, internal precision of the amount
|
||||
would be displayed.
|
||||
*/
|
||||
#ifdef HAVE_GDTOA
|
||||
double to_double(bool no_check = false) const;
|
||||
#endif
|
||||
long to_long(bool no_check = false) const;
|
||||
string to_string() const;
|
||||
string to_fullstring() const;
|
||||
string quantity_string() const;
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
bool fits_in_double() const;
|
||||
#endif
|
||||
bool fits_in_long() const;
|
||||
bool fits_in_double() const;
|
||||
bool fits_in_long() const;
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
|
|
|||
|
|
@ -115,13 +115,11 @@ public:
|
|||
if (! amt.is_realzero())
|
||||
amounts.insert(amounts_map::value_type(&amt.commodity(), amt));
|
||||
}
|
||||
#ifdef HAVE_GDTOA
|
||||
balance_t(const double val) {
|
||||
TRACE_CTOR(balance_t, "const double");
|
||||
amounts.insert
|
||||
(amounts_map::value_type(amount_t::current_pool->null_commodity, val));
|
||||
}
|
||||
#endif
|
||||
balance_t(const unsigned long val) {
|
||||
TRACE_CTOR(balance_t, "const unsigned long");
|
||||
amounts.insert
|
||||
|
|
@ -236,11 +234,9 @@ public:
|
|||
|
||||
virtual balance_t& operator*=(const amount_t& amt);
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
balance_t& operator*=(const double val) {
|
||||
return *this *= amount_t(val);
|
||||
}
|
||||
#endif
|
||||
balance_t& operator*=(const unsigned long val) {
|
||||
return *this *= amount_t(val);
|
||||
}
|
||||
|
|
@ -250,11 +246,9 @@ public:
|
|||
|
||||
virtual balance_t& operator/=(const amount_t& amt);
|
||||
|
||||
#ifdef HAVE_GDTOA
|
||||
balance_t& operator/=(const double val) {
|
||||
return *this /= amount_t(val);
|
||||
}
|
||||
#endif
|
||||
balance_t& operator/=(const unsigned long val) {
|
||||
return *this /= amount_t(val);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,11 +113,9 @@ public:
|
|||
: balance_t(amt), cost(cost_amt) {
|
||||
TRACE_CTOR(balance_pair_t, "const amount_t&, const amount_t&");
|
||||
}
|
||||
#ifdef HAVE_GDTOA
|
||||
balance_pair_t(const double val) : balance_t(val) {
|
||||
TRACE_CTOR(balance_pair_t, "const double");
|
||||
}
|
||||
#endif
|
||||
balance_pair_t(const unsigned long val) : balance_t(val) {
|
||||
TRACE_CTOR(balance_pair_t, "const unsigned long");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,9 +121,6 @@ typedef std::ostream::pos_type ostream_pos_type;
|
|||
#endif
|
||||
|
||||
#include <gmp.h>
|
||||
#ifdef HAVE_GDTOA
|
||||
#include "gdtoa.h"
|
||||
#endif
|
||||
#include "SHA1.h"
|
||||
|
||||
#include "irrXML.h" // XML parser
|
||||
|
|
|
|||
|
|
@ -78,14 +78,9 @@ class value_t
|
|||
multiplicative<value_t, balance_pair_t,
|
||||
multiplicative<value_t, balance_t,
|
||||
ordered_field_operators<value_t, amount_t,
|
||||
#ifdef HAVE_GDTOA
|
||||
ordered_field_operators<value_t, double,
|
||||
#endif
|
||||
ordered_field_operators<value_t, unsigned long,
|
||||
ordered_field_operators<value_t, long> > > > > > > > > >
|
||||
#ifdef HAVE_GDTOA
|
||||
>
|
||||
#endif
|
||||
ordered_field_operators<value_t, long> > > > > > > > > > >
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -288,12 +283,10 @@ public:
|
|||
TRACE_CTOR(value_t, "const unsigned long");
|
||||
set_amount(val);
|
||||
}
|
||||
#ifdef HAVE_GDTOA
|
||||
value_t(const double val) {
|
||||
TRACE_CTOR(value_t, "const double");
|
||||
set_amount(val);
|
||||
}
|
||||
#endif
|
||||
value_t(const amount_t& val) {
|
||||
TRACE_CTOR(value_t, "const amount_t&");
|
||||
set_amount(val);
|
||||
|
|
|
|||
|
|
@ -423,10 +423,8 @@ void AmountTestCase::testComparisons()
|
|||
assertTrue(100L > x1);
|
||||
assertTrue(x1 < 100UL);
|
||||
assertTrue(100UL > x1);
|
||||
#ifdef HAVE_GDTOA
|
||||
assertTrue(x1 < 100.0);
|
||||
assertTrue(100.0 > x1);
|
||||
#endif
|
||||
|
||||
assertValid(x0);
|
||||
assertValid(x1);
|
||||
|
|
@ -540,9 +538,7 @@ void AmountTestCase::testCommodityAddition()
|
|||
assertThrow(x1 + x4, amount_error);
|
||||
assertThrow(x1 + x5, amount_error);
|
||||
assertThrow(x1 + x6, amount_error);
|
||||
#ifdef HAVE_GDTOA
|
||||
assertThrow(x1 + 123.45, amount_error);
|
||||
#endif
|
||||
assertThrow(x1 + 123L, amount_error);
|
||||
|
||||
assertEqual(amount_t("DM 246.90"), x3 + x3);
|
||||
|
|
@ -656,9 +652,7 @@ void AmountTestCase::testCommoditySubtraction()
|
|||
assertThrow(x1 - x4, amount_error);
|
||||
assertThrow(x1 - x5, amount_error);
|
||||
assertThrow(x1 - x6, amount_error);
|
||||
#ifdef HAVE_GDTOA
|
||||
assertThrow(x1 - 123.45, amount_error);
|
||||
#endif
|
||||
assertThrow(x1 - 123L, amount_error);
|
||||
|
||||
assertEqual(amount_t("DM 0.00"), x3 - x3);
|
||||
|
|
@ -871,6 +865,9 @@ void AmountTestCase::testIntegerDivision()
|
|||
assertEqual(amount_t(1L), x4 / x4);
|
||||
assertEqual(amount_t("2204585520061728377204585.517857"), x4 / y4);
|
||||
|
||||
assertEqual(amount_t("0.000000000000000000000000000001"),
|
||||
amount_t("10") / amount_t("10000000000000000000000000000000"));
|
||||
|
||||
assertValid(x1);
|
||||
assertValid(y1);
|
||||
assertValid(x4);
|
||||
|
|
@ -1386,14 +1383,10 @@ void AmountTestCase::testIntegerConversion()
|
|||
amount_t x2("12345682348723487324");
|
||||
|
||||
assertThrow(x0.to_long(), amount_error);
|
||||
#ifdef HAVE_GDTOA
|
||||
assertThrow(x0.to_double(), amount_error);
|
||||
#endif
|
||||
assertFalse(x2.fits_in_long());
|
||||
assertEqual(123456L, x1.to_long());
|
||||
#ifdef HAVE_GDTOA
|
||||
assertEqual(123456.0, x1.to_double());
|
||||
#endif
|
||||
assertEqual(string("123456"), x1.to_string());
|
||||
assertEqual(string("123456"), x1.quantity_string());
|
||||
|
||||
|
|
@ -1406,14 +1399,10 @@ void AmountTestCase::testFractionalConversion()
|
|||
amount_t x2("1234.5683787634678348734");
|
||||
|
||||
assertThrow(x1.to_long(), amount_error); // loses precision
|
||||
#ifdef HAVE_GDTOA
|
||||
assertThrow(x2.to_double(), amount_error); // loses precision
|
||||
assertFalse(x2.fits_in_double());
|
||||
#endif
|
||||
assertEqual(1234L, x1.to_long(true));
|
||||
#ifdef HAVE_GDTOA
|
||||
assertEqual(1234.56, x1.to_double());
|
||||
#endif
|
||||
assertEqual(string("1234.56"), x1.to_string());
|
||||
assertEqual(string("1234.56"), x1.quantity_string());
|
||||
|
||||
|
|
@ -1426,9 +1415,7 @@ void AmountTestCase::testCommodityConversion()
|
|||
|
||||
assertThrow(x1.to_long(), amount_error); // loses precision
|
||||
assertEqual(1234L, x1.to_long(true));
|
||||
#ifdef HAVE_GDTOA
|
||||
assertEqual(1234.56, x1.to_double());
|
||||
#endif
|
||||
assertEqual(string("$1234.56"), x1.to_string());
|
||||
assertEqual(string("1234.56"), x1.quantity_string());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue