summaryrefslogtreecommitdiff
path: root/src/amount.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-06-15 17:40:17 +0100
committerJohn Wiegley <johnw@newartisans.com>2009-06-15 17:52:38 +0100
commit092bda14359d414e1b1e62184cc4d927a4154348 (patch)
tree6af29dedd499de5944bc1998b0a74165b84648cf /src/amount.cc
parent981dc41eb7d0bfd04c23c4f208f76e986cd7007a (diff)
downloadfork-ledger-092bda14359d414e1b1e62184cc4d927a4154348.tar.gz
fork-ledger-092bda14359d414e1b1e62184cc4d927a4154348.tar.bz2
fork-ledger-092bda14359d414e1b1e62184cc4d927a4154348.zip
Don't increase precision so much when dividing
Slow the increase in internal precision when dividing amounts. Use "--debug amount.convert" if you wish to see this logic in action, if a case where incorrect rounding is suspected comes up. Fixes B68FFB0D-A9A0-479C-A6C0-68853F229333
Diffstat (limited to 'src/amount.cc')
-rw-r--r--src/amount.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/amount.cc b/src/amount.cc
index a58cc215..ee241796 100644
--- a/src/amount.cc
+++ b/src/amount.cc
@@ -343,8 +343,8 @@ amount_t& amount_t::operator*=(const amount_t& amt)
_dup();
mpq_mul(MP(quantity), MP(quantity), MP(amt.quantity));
- quantity->prec = static_cast<precision_t>(quantity->prec +
- amt.quantity->prec);
+ quantity->prec =
+ static_cast<precision_t>(quantity->prec + amt.quantity->prec);
if (! has_commodity())
commodity_ = amt.commodity_;
@@ -382,7 +382,7 @@ amount_t& amount_t::operator/=(const amount_t& amt)
mpq_div(MP(quantity), MP(quantity), MP(amt.quantity));
quantity->prec =
static_cast<precision_t>(quantity->prec + amt.quantity->prec +
- quantity->prec + extend_by_digits);
+ extend_by_digits);
if (! has_commodity())
commodity_ = amt.commodity_;