From 85c92e10db043170adbe9a36152907dbb0ea8138 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 30 Sep 2003 07:17:02 +0000 Subject: *** empty log message *** --- amount.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'amount.cc') diff --git a/amount.cc b/amount.cc index 8a880e5b..69b3a6bd 100644 --- a/amount.cc +++ b/amount.cc @@ -268,7 +268,11 @@ static std::string amount_to_str(const commodity * comm, const mpz_t val, if (negative) s << "-"; - if (comm->thousands) { + if (mpz_sgn(quotient) == 0) + s << '0'; + else if (! comm->thousands) + s << quotient; + else { // jww (2003-09-29): use a smarter starting value bool printed = false; @@ -298,8 +302,6 @@ static std::string amount_to_str(const commodity * comm, const mpz_t val, printed = true; } } - } else { - s << quotient; } if (comm->european) @@ -320,7 +322,8 @@ static std::string amount_to_str(const commodity * comm, const mpz_t val, width = MAX_PRECISION - width; - while (p >= buf && *p == '0') + while (p >= buf && *p == '0' && + (p - buf) >= (comm->precision - width)) p--; *(p + 1) = '\0'; -- cgit v1.2.3