Proposal for modifying gnucash to use exact quantities

Richard Wackerbarth
Sun, 30 Jul 2000 19:50:27 -0500

On Sun, 30 Jul 2000, Jason Rennie wrote:

> said:
> > Therefore it is unnecessary  to carry that denominator with the
> > individual values. It can be retrieved  from the description of the
> > units in those very few places where it actually  gets used.
> Yup.  Makes sense.  One denominator per currency should be plenty.

I guess that that depends on how you define "currency". I might have one 
account denominated in eights of a share of XYZ stock and another in 
hundredths of a share of the same stock. In some respects, they are the 
"same", but they really need different denominators.

Another example might be an account denominated in "cents US" and another in 
"dollars US".

> said:
> > Similar analysis of the "exchange" function will show that you only
> > need the  numerators to do a currency conversion.
> No.  You do need the denominator.  Let's say that I'm converting 1 USD to
> Italian Lira (for example).  The denominator for USD is 100.  The
> denominator for Lira is 1.  The exchange rate is 1000 Lira for 1 USD.
> The 1 USD will be internally represented as 100.  If I use your equation:

You are quoting the wrong exchange rate. You need the rate "100 cents US for 
1000 Lira" because you are not dealing in "dollars US"

This is the problem if you don't carry units along with numbers when you 
assign numbers to values input and output.

> said:
> > integer N2 (of currency C2) = convert_to_integer (N1 * C2 / C1)
> I get N2 = 100 * (1000/1) = 100,000.  Too many Lira!  The real equation
> is:
>   N2 = (N1/D1) * (rate) * D2
> where N1 is the numerator for the first currency, D1 is the denominator
> for the first currency, "rate" is the exchange rate, N2 is the numerator
> for the second currency and N2 is the numerator for the second currency. 
> In your USD/Mexican Pesos example, it just so happened that D1=D2=100 so
> you could safely throw out the denominator terms.

No, the reason is that the rate was expressed in terms of cents and centavos 
which are the units that we are using. On input and output, you must convert 
to the internal units rather than the external units displayed.