r17560 - gnucash/branches/2.2/lib/libqof/qof - [r17554] gnc_numeric: Support reciprocals (negative denominators) in gnc_numeric_to_decimal().

Andreas Köhler andi5 at cvs.gnucash.org
Thu Sep 18 22:18:33 EDT 2008


Author: andi5
Date: 2008-09-18 22:18:32 -0400 (Thu, 18 Sep 2008)
New Revision: 17560
Trac: http://svn.gnucash.org/trac/changeset/17560

Modified:
   gnucash/branches/2.2/lib/libqof/qof/gnc-numeric.c
Log:
[r17554] gnc_numeric: Support reciprocals (negative denominators) in gnc_numeric_to_decimal().

Committed by cedayiv.

Modified: gnucash/branches/2.2/lib/libqof/qof/gnc-numeric.c
===================================================================
--- gnucash/branches/2.2/lib/libqof/qof/gnc-numeric.c	2008-09-19 02:18:20 UTC (rev 17559)
+++ gnucash/branches/2.2/lib/libqof/qof/gnc-numeric.c	2008-09-19 02:18:32 UTC (rev 17560)
@@ -1043,7 +1043,15 @@
 
   converted_val = *a;
   if (converted_val.denom <= 0)
-    return FALSE;
+  {
+    converted_val = gnc_numeric_convert(converted_val, 1, GNC_DENOM_EXACT);
+    if (gnc_numeric_check(converted_val) != GNC_ERROR_OK)
+      return FALSE;
+    *a = converted_val;
+    if (max_decimal_places)
+      *max_decimal_places = decimal_places;
+    return TRUE;
+  }
 
   /* Zero is easily converted. */
   if (converted_val.num == 0)



More information about the gnucash-changes mailing list