*** no comment ***
This commit is contained in:
parent
7b591dd27a
commit
6ac8f7b603
2 changed files with 5 additions and 16 deletions
|
|
@ -810,7 +810,7 @@ std::ostream& operator<<(std::ostream& _out, const amount_t& amt)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (precision) {
|
if (precision) {
|
||||||
out << ((comm.flags() & COMMODITY_STYLE_EUROPEAN) ? ',' : '.');
|
out << ((comm.flags & COMMODITY_STYLE_EUROPEAN) ? ',' : '.');
|
||||||
|
|
||||||
std::ostringstream final;
|
std::ostringstream final;
|
||||||
final.width(precision);
|
final.width(precision);
|
||||||
|
|
@ -828,8 +828,8 @@ std::ostream& operator<<(std::ostream& _out, const amount_t& amt)
|
||||||
|
|
||||||
if (i == len)
|
if (i == len)
|
||||||
out << str;
|
out << str;
|
||||||
else if (i < comm.precision())
|
else if (i < comm.precision)
|
||||||
out << std::string(str, 0, comm.precision());
|
out << std::string(str, 0, comm.precision);
|
||||||
else
|
else
|
||||||
out << std::string(str, 0, i);
|
out << std::string(str, 0, i);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
balance.cc
15
balance.cc
|
|
@ -87,10 +87,7 @@ void balance_t::write(std::ostream& out,
|
||||||
|
|
||||||
balance_t& balance_t::operator*=(const balance_t& bal)
|
balance_t& balance_t::operator*=(const balance_t& bal)
|
||||||
{
|
{
|
||||||
if (! *this || ! bal) {
|
if (amounts.size() == 1 && bal.amounts.size() == 1) {
|
||||||
return (*this = 0L);
|
|
||||||
}
|
|
||||||
else if (amounts.size() == 1 && bal.amounts.size() == 1) {
|
|
||||||
return *this *= (*bal.amounts.begin()).second;
|
return *this *= (*bal.amounts.begin()).second;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -103,15 +100,7 @@ balance_t& balance_t::operator*=(const balance_t& bal)
|
||||||
|
|
||||||
balance_t& balance_t::operator/=(const balance_t& bal)
|
balance_t& balance_t::operator/=(const balance_t& bal)
|
||||||
{
|
{
|
||||||
if (! *this) {
|
if (amounts.size() == 1 && bal.amounts.size() == 1) {
|
||||||
return (*this = 0L);
|
|
||||||
}
|
|
||||||
else if (! bal) {
|
|
||||||
std::ostringstream errmsg;
|
|
||||||
errmsg << "Attempt to divide by zero: " << *this << " / " << bal;
|
|
||||||
throw amount_error(errmsg.str());
|
|
||||||
}
|
|
||||||
else if (amounts.size() == 1 && bal.amounts.size() == 1) {
|
|
||||||
return *this /= (*bal.amounts.begin()).second;
|
return *this /= (*bal.amounts.begin()).second;
|
||||||
}
|
}
|
||||||
else if (*this == bal) {
|
else if (*this == bal) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue