From 9f8a32ab48d38fe74da2042c0a438fc88543acef Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 21 Sep 2004 03:41:40 -0400 Subject: fixed several issues in value_t's core --- amount.cc | 49 +++---------------------------------------------- 1 file changed, 3 insertions(+), 46 deletions(-) (limited to 'amount.cc') 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 -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 \ -- cgit v1.2.3