Schema

David Merrill dmerrill@lupercalia.net
Thu, 14 Dec 2000 18:15:25 -0500


On Thu, Dec 14, 2000 at 05:11:57PM -0500, Derek Atkins wrote:
> David Merrill <dmerrill@lupercalia.net> writes:
> 
> > I *still* don't think I understand how the rational numbers work when
> > working with stocks. An example or two would help. It seems that the
> > denominator value might change based on stock splits and such, for
> > example.
> 
> If you are dealing with real stocks, then your demoninator will be 1
> (as you can only own whole-shares of stock).  If you have a Mutual
> Fund, your demoniator may be 100, 1000, 10000, or even 100000,
> depending on how many decimal places of accuracy you want.
> 
> Consider the gnc_numeric object as a means to represent any arbitrary
> fixed-point (decimal) number with an arbitrary fixed-point precision.
> The demoninator is just the number 10^N where you want N decimal
> places of accuracy.
> 
> > The currency situation is actually quite simple, if I understand it
> > correctly. But stocks have me confusticated.
> 
> It's the same thing.

I believe I now understand how and why it works the way it does. I was
stuck on the idea that the denominator was a conversion from the penny
(smallest unit) to the dollar (standard unit). And this *is* how it
works for currencies, but only as a side product of the algorithm.

It really *is* just a rational number expressed as integer numerator
over integer denominator. Sorry I led you all around in circles to get
back where I started, but hopefully I've not got it well burnt into my
noggin.

-- 
Dr. David C. Merrill                     http://www.lupercalia.net
Linux Documentation Project                dmerrill@lupercalia.net
Collection Editor & Coordinator            http://www.linuxdoc.org
                                       Finger me for my public key

There is no hunting like the hunting of man, and those who have hunted
armed men long enough and liked it, never care for anything else thereafter.
		-- Ernest Hemingway