Floating point exactness & alternatives (summary)

news at usc.edu news at usc.edu
Sun Aug 19 04:09:23 AEST 1990


In article <168 at srchtec.UUCP> johnb at srchtec.UUCP (John Baldwin) writes:
   In article <1990Aug7.173030.2823 at zoo.toronto.edu>
   henry at zoo.toronto.edu (Henry Spencer) writes: 
   >In article <713 at tetrauk.UUCP> rick at tetrauk.UUCP (Rick Jones)
   >writes: 
   >>  Auditors have this annoying view that accounts must balance to
   >>  the penny, not 1 part in 10 to-the-something.  There is a good
   >>  case for using some form of BCD representation, but there are
   >>  many programming advantages in using the embedded numerical
   >>  types of the language... 
   >
   >Our own experience, in building accounting systems for our own
   >use, is that the problem can often be eliminated by ignoring the
   >decimal point in dollar currencies and thinking of money as
   >measured in pennies. 

This is very true.  Units of money should never be stored as
fractions.  BCD is merely one technique of ensuring this.

   Doesn't this push him back into the "continued sums"
   implementation?  Remember, conversion rates between different
   currencies "slide" up and down at a fairly high frequency.  (Does
   anybody know just HOW frequently the exchange rates change?)

   This would require an INTERNAL currency which would probably NOT be
   the same as a recognized world currency; one in which any unit of
   any other world currency can be expressed as an integer.  This is
   probably tricky enough to find WITHOUT having the conversions
   changing on you all the time!

The only solution I know of to the multiple currency problem is to
keep records in the same form as the real world entities they
represent.  If you have two apples and three oranges, and the exchange
rate is currently 1 apple = 1 orange, that does not mean you have 5
apples nor does it mean you have 5 oranges.  The exchange rate only
exists when there is an exchange, and is only set for that exchange.
(Not to be confused with a transaction, which might consiste of many
exchanges.)

wulkwa



More information about the Comp.lang.c mailing list