Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!newsfeed.internetmci.com!EU.net!news2.EUnet.fr!news.fnet.fr!ilog!news
From: parquier@halles.ilog.fr (Pierre Parquier)
Subject: Re: Gnu Common Lisp HELP!
In-Reply-To: will@ccs.neu.edu's message of 12 Jan 1996 16:18:25 GMT
Message-ID: <PARQUIER.96Jan14182219@halles.ilog.fr>
Lines: 41
Sender: news@ilog.fr
Nntp-Posting-Host: halles
Organization: ILOG S.A., Gentilly, France
References: <30F51D2D.C84@ling.umu.se> <19960111T202920Z@arcana.naggum.no>
	<4d61kh$tj@camelot.ccs.neu.edu>
Date: 14 Jan 1996 17:22:18 GMT


wdc>  I concur with Erik Naggum's recommendation that monetary
wdc>  quantities, and related quantities such as interest rates,
wdc>  should be represented by exact rational numbers, not inexact
wdc>  floating point numbers.

I beg to disagree.  CoBOL has addressed this issues for decades (its
core business, so to speak), and felt no need for rational.  Why?

First, the problem with rational for monetary matters: there are not
enough operations defined on ratios for accounting.  Eg you cannot
compute a monthly interest rate give a yearly interest rate.

Second, how do CoBOL folks manage monetary items: they use integers
for quantities (ok, fixed point values, but that's essentially the
same, and that's very different from a ratio), rates to be applied
only to these quantities, and reserve floats for more complex
computation.  Using float all around is a beginner mistake in CoBOL.

The justification for this is that in accounting, there *is* an notion
of error (unlike ratio), but on the contrary to IEEE floats, it is
under total control (I mean of the average acounting clerk or
programmer, quite unlike the average engineer).

In finance, the story is very different, and the quantities are more
like physical quantities, therefore floats are usually prefered.  But
I felt you were more in the accounting sphere.

Bottom line is that if you are more serious about accounting in Lisp,
you should create your monetary classes, whose attributes are:
accuracy (to the cent, tenth of a cent...), number of minute units (an
integer), monerary unit (USD, GBP,...), perhaps another class for
rates, maybe more.

Now let's be real, for toy accounting (ie no error programming),
floats are good enough, with proper output formating.

   __________________________________________________
   Pierre Parquier                   parquier@ilog.fr
   ILOG S.A.                      http://www.ilog.com
   *** Use Lisp for C++ libraries: use Ilog Talk! ***
