From bbb8d1be338218cabd43145e6cb675f7e34879d8 Mon Sep 17 00:00:00 2001 From: Chris Shoemaker Date: Sat, 4 Feb 2006 15:06:19 +0000 Subject: [PATCH] Teach PrintAmountInternal() to correctly handle a reciprocal denominator. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@13091 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/app-utils/gnc-ui-util.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app-utils/gnc-ui-util.c b/src/app-utils/gnc-ui-util.c index 4d1d12feae..4fe91e00ea 100644 --- a/src/app-utils/gnc-ui-util.c +++ b/src/app-utils/gnc-ui-util.c @@ -1198,8 +1198,8 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info) } /* calculate the integer part and the remainder */ - whole = gnc_numeric_create (val.num / val.denom, 1); - val = gnc_numeric_sub (val, whole, val.denom, GNC_RND_NEVER); + whole = gnc_numeric_convert(val, 1, GNC_HOW_RND_TRUNC); + val = gnc_numeric_sub (val, whole, GNC_DENOM_AUTO, GNC_HOW_RND_NEVER); if (gnc_numeric_check (val)) { PWARN ("Problem with remainder."); @@ -1282,9 +1282,12 @@ PrintAmountInternal(char *buf, gnc_numeric val, const GNCPrintAmountInfo *info) { val = gnc_numeric_reduce (val); - sprintf (temp_buf, " + %" G_GINT64_FORMAT " / %" G_GINT64_FORMAT, - val.num, - val.denom); + if (val.denom > 0) + sprintf (temp_buf, " + %" G_GINT64_FORMAT " / %" G_GINT64_FORMAT, + val.num, val.denom); + else + sprintf (temp_buf, " + %" G_GINT64_FORMAT " * %" G_GINT64_FORMAT, + val.num, -val.denom); strcat (buf, temp_buf); }