diff options
Diffstat (limited to 'amount.cc')
-rw-r--r-- | amount.cc | 49 |
1 files changed, 3 insertions, 46 deletions
@@ -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 \ |