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
This commit is contained in:
Charles Day 2008-09-18 08:33:27 +00:00
parent a7e8bd5499
commit ad6df218a0

View File

@ -1043,7 +1043,15 @@ gnc_numeric_to_decimal(gnc_numeric *a, guint8 *max_decimal_places)
converted_val = *a; converted_val = *a;
if (converted_val.denom <= 0) 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. */ /* Zero is easily converted. */
if (converted_val.num == 0) if (converted_val.num == 0)