[Gnucash-changes] r13091 - gnucash/trunk/src/app-utils - Teach PrintAmountInternal() to correctly handle a reciprocal denominator.

Chris Shoemaker chris at cvs.gnucash.org
Sat Feb 4 10:06:20 EST 2006


Author: chris
Date: 2006-02-04 10:06:19 -0500 (Sat, 04 Feb 2006)
New Revision: 13091
Trac: http://svn.gnucash.org/trac/changeset/13091

Modified:
   gnucash/trunk/src/app-utils/gnc-ui-util.c
Log:
   Teach PrintAmountInternal() to correctly handle a reciprocal denominator.


Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c	2006-02-04 05:37:50 UTC (rev 13090)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2006-02-04 15:06:19 UTC (rev 13091)
@@ -1198,8 +1198,8 @@
   }
 
   /* 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 @@
     {
       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);
     }



More information about the gnucash-changes mailing list