Subject: Re: Gnu Common Lisp HELP!
From: Erik Naggum <>
Date: 1996/01/14
Newsgroups: comp.lang.lisp
Message-ID: <>

[Pierre Parquier]

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

because Cobol has a different set of types than Common Lisp has, obviously.
case in point: Common Lisp does not have fixed-point numbers, and Cobol
does not have ratios.  you pick what you need from what you can.  since
this is not comp.lang.cobol, but comp.lang.lisp, I thought my answer should
address this audience.  I did not intend to argue against other language's
more (or less) appropriate types for representing monetary values, only to
argue against the usage of floating point to represent monetary values when
Common Lisp offers rationals, which is a far better type, especially with
bignums for both numerator and denominator.

|   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.

this I do not understand.  interest rate and the period of compounding are
separate concepts, at least as I learned accounting (it has been 15 years
-- updates accepted), and one may very well divide an annual interest rate
by 12 (a well-defined operation over ratios) to obtain a monthly interest
rate if the period of compounding is the same (a year), but since annual
compounding cannot be turned into monthly compounding, there is no way you
can compute a monthly interest rate that will yield the same compound
interest without knowing the term of the loan or the investment.

|   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.

this, too, I do not understand.  a fixed-point value is a ratio with a
constant denominator, is it not?  I donated my copy of the ANSI Cobol
standard to my University's computer lab 5 years ago, but from my
admittedly rusty memory of reading it, there should be no difference from
computing with ratios.  transcendental operations are well-defined for
ratios; they are coerced to floating-point -- coercing back to rational
with a constant denominator entertains the same notion of error that you
have in fixed-point numbers.  (transcendental operations may be computed by
mathematical series of fractions and non-transcendental operations.  except
for the obvious issue of speed, there is no need to leave rational space.)

|   In finance, the story is very different, and the quantities are more
|   like physical quantities, therefore floats are usually prefered.

I had not thought of that, but it is clearly a valid observation.

#<Erik 3030650282>
the problem with this "information superhighway" is mainly that if you ask
people to go play in it, they don't even understand when they get run over.