summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2008-07-28 02:04:29 -0400
committerJohn Wiegley <johnw@newartisans.com>2008-07-28 02:04:29 -0400
commitdede5e71bf562f43000bc88bad67688fb88f841e (patch)
tree52f79ea845380f2ed3c27147b908bdde63de531e /amount.cc
parentc93175183e790cf7f1100dfd554197161a69e6fe (diff)
downloadledger-dede5e71bf562f43000bc88bad67688fb88f841e.tar.gz
ledger-dede5e71bf562f43000bc88bad67688fb88f841e.tar.bz2
ledger-dede5e71bf562f43000bc88bad67688fb88f841e.zip
Corrected a bad rounding bug that affecting very small commodity entries.
Diffstat (limited to 'amount.cc')
-rw-r--r--amount.cc8
1 files changed, 3 insertions, 5 deletions
diff --git a/amount.cc b/amount.cc
index 3a10828c..087a9bc5 100644
--- a/amount.cc
+++ b/amount.cc
@@ -548,14 +548,12 @@ amount_t::operator bool() const
if (! quantity)
return false;
- if (quantity->prec <= commodity().precision()) {
+ if (quantity->prec <= commodity().precision() ||
+ (quantity->flags & BIGINT_KEEP_PREC)) {
return mpz_sgn(MPZ(quantity)) != 0;
} else {
mpz_set(temp, MPZ(quantity));
- if (quantity->flags & BIGINT_KEEP_PREC)
- mpz_ui_pow_ui(divisor, 10, quantity->prec);
- else
- mpz_ui_pow_ui(divisor, 10, quantity->prec - commodity().precision());
+ mpz_ui_pow_ui(divisor, 10, quantity->prec - commodity().precision());
mpz_tdiv_q(temp, temp, divisor);
bool zero = mpz_sgn(temp) == 0;
return ! zero;