mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
bug fix for rounding suggested by Dave petticolas
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@1959 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -190,6 +190,10 @@ PrtAmtComma (char * buf, double val, int prec)
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* Round to 100'ths or 1000'nths now. Must do this before we start printing. */
|
||||
if (2 == prec) val += 0.005;
|
||||
if (3 == prec) val += 0.0005;
|
||||
|
||||
/* count number of commas */
|
||||
tmp = val;
|
||||
while (tmp > 1000.0) {
|
||||
@@ -197,7 +201,7 @@ PrtAmtComma (char * buf, double val, int prec)
|
||||
ncommas ++;
|
||||
}
|
||||
|
||||
/* print digits in groups of three, seperated by commas */
|
||||
/* print digits in groups of three, separated by commas */
|
||||
for (i=ncommas; i>=0; i--) {
|
||||
int j;
|
||||
|
||||
@@ -220,10 +224,10 @@ PrtAmtComma (char * buf, double val, int prec)
|
||||
|
||||
/* print two or three decimal places */
|
||||
if (3 == prec) {
|
||||
ival = 0.5 + 1000.0 * (val-amt);
|
||||
ival = 1000.0 * (val-amt);
|
||||
buf += sprintf (buf, "%03d", ival);
|
||||
} else {
|
||||
ival = 0.5 + 100.0 * (val-amt);
|
||||
ival = 100.0 * (val-amt);
|
||||
buf += sprintf (buf, "%02d", ival);
|
||||
}
|
||||
|
||||
@@ -237,6 +241,9 @@ xaccSPrintAmount (char * bufp, double val, short shrs)
|
||||
|
||||
if (!bufp) return 0;
|
||||
|
||||
if (DEQ(val, 0.0))
|
||||
val = 0.0;
|
||||
|
||||
if (0.0 > val) {
|
||||
bufp[0] = '-';
|
||||
bufp ++;
|
||||
|
||||
Reference in New Issue
Block a user