summaryrefslogtreecommitdiff
path: root/src/balance.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-05-07 10:24:46 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:38 -0400
commit06e7c2820242ea5130a63305836f822ccb409a92 (patch)
treed59d4ad1e85c0319cebe203858bf1924ffa1d205 /src/balance.cc
parent7868a53b70bd08b79007386dbb5b1590bfb2e457 (diff)
downloadfork-ledger-06e7c2820242ea5130a63305836f822ccb409a92.tar.gz
fork-ledger-06e7c2820242ea5130a63305836f822ccb409a92.tar.bz2
fork-ledger-06e7c2820242ea5130a63305836f822ccb409a92.zip
Rearranged many method names.
Diffstat (limited to 'src/balance.cc')
-rw-r--r--src/balance.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/balance.cc b/src/balance.cc
index dd822963..cafd0f01 100644
--- a/src/balance.cc
+++ b/src/balance.cc
@@ -4,8 +4,11 @@ namespace ledger {
balance_t& balance_t::operator*=(const balance_t& bal)
{
- if (realzero() || bal.realzero()) {
- return *this = amount_t();
+ if (is_realzero()) {
+ return *this;
+ }
+ else if (bal.is_realzero()) {
+ return *this = bal;
}
else if (bal.amounts.size() == 1) {
return *this *= (*bal.amounts.begin()).second;
@@ -34,8 +37,11 @@ balance_t& balance_t::operator*=(const balance_t& bal)
balance_t& balance_t::operator*=(const amount_t& amt)
{
- if (realzero() || amt.realzero()) {
- return *this = amount_t();
+ if (is_realzero()) {
+ return *this;
+ }
+ else if (amt.is_realzero()) {
+ return *this = amt;
}
else if (! amt.commodity()) {
// Multiplying by the null commodity causes all amounts to be
@@ -72,11 +78,11 @@ balance_t& balance_t::operator*=(const amount_t& amt)
balance_t& balance_t::operator/=(const balance_t& bal)
{
- if (bal.realzero()) {
+ if (bal.is_realzero()) {
throw_(amount_error, "Divide by zero: " << *this << " / " << bal);
}
- else if (realzero()) {
- return *this = amount_t();
+ else if (is_realzero()) {
+ return *this;
}
else if (bal.amounts.size() == 1) {
return *this /= (*bal.amounts.begin()).second;
@@ -97,11 +103,11 @@ balance_t& balance_t::operator/=(const balance_t& bal)
balance_t& balance_t::operator/=(const amount_t& amt)
{
- if (amt.realzero()) {
+ if (amt.is_realzero()) {
throw_(amount_error, "Divide by zero: " << *this << " / " << amt);
}
- else if (realzero()) {
- return *this = amount_t();
+ else if (is_realzero()) {
+ return *this;
}
else if (! amt.commodity()) {
// Dividing by the null commodity causes all amounts to be