diff options
author | John Wiegley <johnw@newartisans.com> | 2009-01-31 04:25:05 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-01-31 04:25:05 -0400 |
commit | e9ff5caa13e2d60681010dbedcf56459ee7521a4 (patch) | |
tree | 056a124c232daccb3dcc616a32fb3b2a9c217d86 /python | |
parent | c96ab6cb0fb289cd50fb239ba44c01aba131fc18 (diff) | |
download | fork-ledger-e9ff5caa13e2d60681010dbedcf56459ee7521a4.tar.gz fork-ledger-e9ff5caa13e2d60681010dbedcf56459ee7521a4.tar.bz2 fork-ledger-e9ff5caa13e2d60681010dbedcf56459ee7521a4.zip |
Rationals based math is now passing the unit tests.
Diffstat (limited to 'python')
-rw-r--r-- | python/py_amount.cc | 73 | ||||
-rw-r--r-- | python/py_value.cc | 7 |
2 files changed, 40 insertions, 40 deletions
diff --git a/python/py_amount.cc b/python/py_amount.cc index b57687f2..2528f779 100644 --- a/python/py_amount.cc +++ b/python/py_amount.cc @@ -41,29 +41,6 @@ namespace ledger { using namespace boost::python; -#ifdef INTEGER_MATH -amount_t py_round_0(const amount_t& amount) { - return amount.round(); -} -amount_t py_round_1(const amount_t& amount, amount_t::precision_t prec) { - return amount.round(prec); -} -#endif - -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); -} - -long py_to_long_0(amount_t& amount) { - return amount.to_long(); -} -long py_to_long_1(amount_t& amount, bool no_check) { - return amount.to_long(no_check); -} - boost::optional<amount_t> py_value_0(const amount_t& amount) { return amount.value(); } @@ -169,7 +146,9 @@ void export_amount() make_getter(&amount_t::stream_fullstrings), make_setter(&amount_t::stream_fullstrings)) +#if 0 .def(init<double>()) +#endif .def(init<long>()) .def(init<std::string>()) @@ -185,80 +164,108 @@ internal precision.") .def(self == self) .def(self == long()) .def(long() == self) +#if 0 .def(self == double()) .def(double() == self) +#endif .def(self != self) .def(self != long()) .def(long() != self) +#if 0 .def(self != double()) .def(double() != self) +#endif .def(! self) .def(self < self) .def(self < long()) .def(long() < self) +#if 0 .def(self < double()) .def(double() < self) +#endif .def(self <= self) .def(self <= long()) .def(long() <= self) +#if 0 .def(self <= double()) .def(double() <= self) +#endif .def(self > self) .def(self > long()) .def(long() > self) +#if 0 .def(self > double()) .def(double() > self) +#endif .def(self >= self) .def(self >= long()) .def(long() >= self) +#if 0 .def(self >= double()) .def(double() >= self) +#endif .def(self += self) .def(self += long()) +#if 0 .def(self += double()) +#endif .def(self + self) .def(self + long()) .def(long() + self) +#if 0 .def(self + double()) .def(double() + self) +#endif .def(self -= self) .def(self -= long()) +#if 0 .def(self -= double()) +#endif .def(self - self) .def(self - long()) .def(long() - self) +#if 0 .def(self - double()) .def(double() - self) +#endif .def(self *= self) .def(self *= long()) +#if 0 .def(self *= double()) +#endif .def(self * self) .def(self * long()) .def(long() * self) +#if 0 .def(self * double()) .def(double() * self) +#endif .def(self /= self) .def(self /= long()) +#if 0 .def(self /= double()) +#endif .def(self / self) .def(self / long()) .def(long() / self) +#if 0 .def(self / double()) .def(double() / self) +#endif .def("precision", &amount_t::precision) @@ -270,11 +277,8 @@ internal precision.") .def("abs", &amount_t::abs) .def("__abs__", &amount_t::abs) -#ifdef INTEGER_MATH - .def("round", py_round_0) - .def("round", py_round_1) -#endif - .def("unround", &amount_t::unround) + .def("rounded", &amount_t::rounded) + .def("unrounded", &amount_t::unrounded) .def("reduce", &amount_t::reduce) .def("in_place_reduce", &amount_t::in_place_reduce, @@ -295,18 +299,15 @@ internal precision.") .def("is_realzero", &amount_t::is_realzero) .def("is_null", &amount_t::is_null) - .def("to_double", py_to_double_0) - .def("to_double", py_to_double_1) - .def("__float__", py_to_double_0) - .def("to_long", py_to_long_0) - .def("to_long", py_to_long_1) - .def("__int__", py_to_long_0) + .def("to_double", &amount_t::to_double) + .def("__float__", &amount_t::to_double) + .def("to_long", &amount_t::to_long) + .def("__int__", &amount_t::to_long) .def("to_string", &amount_t::to_string) .def("__str__", &amount_t::to_string) .def("to_fullstring", &amount_t::to_fullstring) .def("__repr__", &amount_t::to_fullstring) - .def("fits_in_double", &amount_t::fits_in_double) .def("fits_in_long", &amount_t::fits_in_long) .def("quantity_string", &amount_t::quantity_string) @@ -359,7 +360,9 @@ internal precision.") register_optional_to_python<amount_t>(); +#if 0 implicitly_convertible<double, amount_t>(); +#endif implicitly_convertible<long, amount_t>(); implicitly_convertible<string, amount_t>(); diff --git a/python/py_value.cc b/python/py_value.cc index 48cd0feb..4556c31e 100644 --- a/python/py_value.cc +++ b/python/py_value.cc @@ -195,11 +195,8 @@ void export_value() .def("abs", &value_t::abs) .def("__abs__", &value_t::abs) -#ifdef INTEGER_MATH - .def("round", &value_t::round) - .def("in_place_round", &value_t::in_place_round) -#endif - .def("unround", &value_t::unround) + .def("rounded", &value_t::rounded) + .def("unrounded", &value_t::unrounded) .def("reduce", &value_t::reduce) .def("in_place_reduce", &value_t::in_place_reduce) |