summaryrefslogtreecommitdiff
path: root/amount.cc
diff options
context:
space:
mode:
Diffstat (limited to 'amount.cc')
-rw-r--r--amount.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/amount.cc b/amount.cc
index 1a538f40..69ac1738 100644
--- a/amount.cc
+++ b/amount.cc
@@ -489,9 +489,11 @@ amount_t::operator bool() const
if (quantity->prec <= commodity().precision) {
return mpz_sgn(MPZ(quantity)) != 0;
} else {
- assert(commodity_);
mpz_set(temp, MPZ(quantity));
- mpz_ui_pow_ui(divisor, 10, quantity->prec - commodity().precision);
+ if (commodity_)
+ mpz_ui_pow_ui(divisor, 10, quantity->prec - commodity_->precision);
+ else
+ mpz_ui_pow_ui(divisor, 10, quantity->prec);
mpz_tdiv_q(temp, temp, divisor);
bool zero = mpz_sgn(temp) == 0;
return ! zero;