diff options
Diffstat (limited to 'src/amount.cc')
-rw-r--r-- | src/amount.cc | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/amount.cc b/src/amount.cc index ae61495c..653272ed 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -100,8 +100,6 @@ uint_fast32_t amount_t::sizeof_bigint_t() return sizeof(bigint_t); } -amount_t * one = NULL; - void amount_t::initialize() { mpz_init(temp); @@ -109,8 +107,6 @@ void amount_t::initialize() mpfr_init(tempf); mpfr_init(tempfb); - one = new amount_t(amount_t(1L).unrounded()); - if (! current_pool) current_pool = new commodity_pool_t; @@ -133,8 +129,6 @@ void amount_t::shutdown() mpfr_clear(tempf); mpfr_clear(tempfb); - checked_delete(one); - if (current_pool) { checked_delete(current_pool); current_pool = NULL; @@ -455,6 +449,18 @@ amount_t& amount_t::in_place_negate() return *this; } +amount_t amount_t::inverted() const +{ + if (! quantity) + throw_(amount_error, "Cannot invert an uninitialized amount"); + + amount_t t(*this); + t._dup(); + mpq_inv(MP(t.quantity), MP(t.quantity)); + + return t; +} + amount_t amount_t::rounded() const { if (! quantity) |