From ad6df218a0ebeee93b835f098e4e2924479c8c21 Mon Sep 17 00:00:00 2001 From: Charles Day Date: Thu, 18 Sep 2008 08:33:27 +0000 Subject: [PATCH] gnc_numeric: Support reciprocals (negative denominators) in gnc_numeric_to_decimal(). BP git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17554 57a11ea4-9604-0410-9ed3-97b8803252fd --- lib/libqof/qof/gnc-numeric.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/libqof/qof/gnc-numeric.c b/lib/libqof/qof/gnc-numeric.c index 6251837653..0855c7e279 100644 --- a/lib/libqof/qof/gnc-numeric.c +++ b/lib/libqof/qof/gnc-numeric.c @@ -1043,7 +1043,15 @@ gnc_numeric_to_decimal(gnc_numeric *a, guint8 *max_decimal_places) 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)