fractional parts

Christopher Browne cbbrowne@hex.net
Wed, 19 Jul 2000 21:57:58 -0500

```On Wed, 19 Jul 2000 20:28:11 -0400, the world broke into rejoicing as
Matthew Lepper <mlepper@bellatlantic.net>  said:
> I think the way to use this factoid is to define a data type
> that uses three integers to represent values:
> 1) integer units -- for USD this would be dollars
> 2) fractional numerator
> 3) fractional denominator
>
> This basic structure may have been proposed and dismissed
>
> This would allow you to do exact math on almost all
> resonable bits and peices of a base unit.  It seems
> appropriate that the units would use a 64-bit number and
> the fractional bits would be 32-bit numbers.  Pennies
> would simply use a denominator of 100.  Securities quotes
> would use denominators or 2,4,...  Heck, you could even
> represent old english denominations!
>
> Basic math is simple.  It doesn't help the problem of when
> values get rounded, but it can easily represent the result.

That's an interesting alternative, but still suffers from the same
problem that other "numbers-only" representations have, which is that
the "integer units" and "fractional denominator" are properly
associated not with the value, but rather with the _commodity_.

So that there are _two_ data structures:

a) The Commodity, which has:
1.  A denominator, and

Then you have...

b) Value, which consists of:
1.  The numerator, and
2.  The Commodity identifier.

There can _never_ be a Value on the system that does _not_ have
a Commodity Identifier, because Values do not exist in the abstract,
but only as something associated with a quantity of a Commodity.

The only argument that has persisted is whether or not it is:
a) A Very Good Thing to have the redundant inclusion of the denominator
information associated with each value, or
b) A Very Bad Thing to have this redundancy.

My vote is with this redundancy being Rather Bad.  Richard feels more
strongly than I do.  And there are others that seem to think that
maintaining this redundant information is a Very Good Thing.
--
cbbrowne@ntlug.org - <http://www.hex.net/~cbbrowne/>
Any programmer who fails to comply with the standard naming, formatting,
or commenting conventions should be shot.  If it so happens that it is
inconvenient to shoot him, then he is to be politely requested to recode
his program in adherence to the above standard.
-- Michael Spier, Digital Equipment Corporation

```