summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/amount.cc12
-rw-r--r--src/amount.h6
2 files changed, 12 insertions, 6 deletions
diff --git a/src/amount.cc b/src/amount.cc
index 653272ed..bc8b0b6f 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -259,6 +259,18 @@ int amount_t::compare(const amount_t& amt) const
return mpq_cmp(MP(quantity), MP(amt.quantity));
}
+bool amount_t::operator==(const amount_t& amt) const
+{
+ if ((quantity && ! amt.quantity) || (! quantity && amt.quantity))
+ return false;
+ else if (! quantity && ! amt.quantity)
+ return true;
+ else if (commodity() != amt.commodity())
+ return false;
+
+ return mpq_equal(MP(quantity), MP(amt.quantity));
+}
+
amount_t& amount_t::operator+=(const amount_t& amt)
{
diff --git a/src/amount.h b/src/amount.h
index ef9fc4b0..d5c759db 100644
--- a/src/amount.h
+++ b/src/amount.h
@@ -781,12 +781,6 @@ inline std::istream& operator>>(std::istream& in, amount_t& amt) {
namespace ledger {
-inline bool amount_t::operator==(const amount_t& amt) const {
- if (commodity() != amt.commodity())
- return false;
- return compare(amt) == 0;
-}
-
inline commodity_t& amount_t::commodity() const {
return has_commodity() ? *commodity_ : *current_pool->null_commodity;
}