diff options
author | John Wiegley <johnw@newartisans.com> | 2004-09-21 03:41:40 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-09-21 03:41:40 -0400 |
commit | 9f8a32ab48d38fe74da2042c0a438fc88543acef (patch) | |
tree | 5b344e35b8f3cb72c04c2e5d9716113e1c09f13e /amount.cc | |
parent | 565a128b1a2eac7d6603d972dd3e14ce80c53c61 (diff) | |
download | fork-ledger-9f8a32ab48d38fe74da2042c0a438fc88543acef.tar.gz fork-ledger-9f8a32ab48d38fe74da2042c0a438fc88543acef.tar.bz2 fork-ledger-9f8a32ab48d38fe74da2042c0a438fc88543acef.zip |
fixed several issues in value_t's core
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 \ |