Proposal for modifying gnucash to use exact quantities

Bill Gribble grib@billgribble.com
Tue, 1 Aug 2000 11:36:28 -0500


On Mon, Jul 31, 2000 at 08:05:04PM -0500, Richard Wackerbarth wrote:
> 2) The "denominator" may need to be the reciprocal of an integer 
> greater than  unity.

Good point.  How about, as was suggested, an idea that the denominator
take on negative values (possibly hidden by a macro, i.e. 
GNC_DENOM_RECIPROCAL(1000) meaning that 1000 currency-units is the
smallest transaction.

this would mean pushing the "special" denominator flags out of the
denom argument, but I was irritated by that anyway.  They could just
be replaced by one special denominator that indicates autocalculation
of the denominator (which would probably be defined to be 0, which 
is never a valid denom) and having the LCD/reduction flags by or'ed in 
with the how argument:
  
   gnc_numeric_add(a, b, GNC_DENOM_AUTO, GNC_DENOM_LEAST | GNC_RND_NEVER)

> 3) There are no constraints to assure that the results remain in the 
> allowable domain of values.

I believe this is addressed by the fact that the output denominator
must be specified in the arithmetic function call.  The constraint
on fixed denomination can be enforced in several ways, from silent
rounding to the correct denomination to reporting an error:

  /* silently correct arguments that may not be denominated in 100ths */
  gnc_numeric_add(a, b, 100, GNC_RND_UNBIAS); 
  
  /* generate an error value and scream bloody murder if denominators 
   * differ from each other, and make sure the output is the same */
  gnc_numeric_add(a, b, GNC_DENOM_FIXED, GNC_RND_NEVER);

In the gnucash code, most of the arithmetic operations to do, for
example, balance summation will use the latter form.  

> 4) I have numerous objections related to efficiency and "cleanliness" of the 
> interface, but they are not strictly complaints about "correctness" if you 
> choose to define that to mean "sufficient to derive the correct answer".

I'd like to hear them.  I want to improve the efficiency and
cleanliness of the interface wherever possible. 

b.g.