summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
Diffstat (limited to 'amount.cc')
-rw-r--r--amount.cc49
1 files changed, 3 insertions, 46 deletions
diff --git a/amount.cc b/amount.cc
index 48af1aa7..2be25f6f 100644
--- a/amount.cc
+++ b/amount.cc
@@ -463,54 +463,11 @@ void amount_t::negate()
}
}
-// integer comparisons
-template <typename T>
-static inline void parse_num(amount_t& amt, T num) {
- std::string str;
- { std::ostringstream strstr(str);
- strstr << num;
- }
- { std::istringstream strstr(str);
- amt.parse(strstr);
- }
-}
-
-#define AMOUNT_CMP_INT(OP) \
-bool amount_t::operator OP (const int num) const \
-{ \
- if (num == 0) { \
- return quantity ? mpz_sgn(MPZ(quantity)) OP 0 : false; \
- } else { \
- amount_t amt; \
- parse_num(amt, num); \
- return *this OP amt; \
- } \
-}
-
-AMOUNT_CMP_INT(<)
-AMOUNT_CMP_INT(<=)
-AMOUNT_CMP_INT(>)
-AMOUNT_CMP_INT(>=)
-AMOUNT_CMP_INT(==)
-
-#define AMOUNT_CMP_UINT(OP) \
-bool amount_t::operator OP (const unsigned int num) const \
-{ \
- if (num == 0) { \
- return quantity ? mpz_sgn(MPZ(quantity)) OP 0 : false; \
- } else { \
- amount_t amt; \
- parse_num(amt, num); \
- return *this OP amt; \
- } \
+int amount_t::sign() const
+{
+ return quantity ? mpz_sgn(MPZ(quantity)) : 0;
}
-AMOUNT_CMP_UINT(<)
-AMOUNT_CMP_UINT(<=)
-AMOUNT_CMP_UINT(>)
-AMOUNT_CMP_UINT(>=)
-AMOUNT_CMP_UINT(==)
-
// comparisons between amounts
#define AMOUNT_CMP_AMOUNT(OP) \
bool amount_t::operator OP(const amount_t& amt) const \