[comp.lang.smalltalk] Fixed Point

georg@exunido.uucp (Georg A. M. Heeg) (07/15/88)

For our internal purposes we need a business calculation program.
We only want to use Smalltalk-80 software.

As basic technology we need decimal fixed point arithmetic.
The fiscal office certainly does not accect rounding errors through
foating point arithmetic....

Is there anyone out there in the world who ever wrote an appropriate
numeric class in Smalltalk-80?

Georg

wcs@skep2.ATT.COM (Bill.Stewart.[ho95c]) (07/17/88)

In article <442@laura.UUCP> georg@unido.UUCP (Georg A. M. Heeg) writes:
:As basic technology we need decimal fixed point arithmetic.
:The fiscal office certainly does not accept rounding errors through
:floating point arithmetic....

Surprise!  You'll get roundoff errors just as badly in fixed decimal,
if you ever do interest rates or division.  Suppose you have an annual
interest rate of 10%, and need to calculate monthly payments.  The
monthly rate is .0833333333..., which will be represented much more
accurately by floating-point than by fixed-point.

You can process the calculations in floating point, and use an
appropriate rounding algorithm for print statements.

A more serious problem is precision - 32 bits is not enough, so
double-precision floating point becomes useful.  If you do your
calculations in exact pennies/pfennig, the maximum amount of money you
can process is about 20 million dollars/marks, which is not enough for
larger businesses.
-- 
#				Thanks;
#Bill Stewart, AT&T Bell Labs 2G218 Holmdel NJ 201-949-0705 ho95c.att.com!wcs

jfh@rpp386.UUCP (John F. Haugh II) (07/17/88)

In article <198@skep2.ATT.COM> wcs@skep2.UUCP (46323-Bill.Stewart.[ho95c],2G218,x0705,) writes:
>In article <442@laura.UUCP> georg@unido.UUCP (Georg A. M. Heeg) writes:
>:As basic technology we need decimal fixed point arithmetic.
>:The fiscal office certainly does not accept rounding errors through
>:floating point arithmetic....
>
>Surprise!  You'll get roundoff errors just as badly in fixed decimal,
>if you ever do interest rates or division.

this is cobol's domain.  all cobol implementations i've used allow you
do declare something like

	05 total-federal-deficit pic 9(15).99
	05 annual-federal-deficit pic 9(12).99

and regardless of floating point word size get accurate results if you
add this years deficit to last years.  double words (32 bit) only yield
seven digits at best, and even quad words (64 bit) yield only 15 digit
accuracy.

no one ever said cobol was fast, but if those damned beancounters want
their pennies, go find a cobol compiler.

- john.
-- 
John F. Haugh II                 +--------- Cute Chocolate Quote ---------
HASA, "S" Division               | "USENET should not be confused with
UUCP:   killer!rpp386!jfh        |  something that matters, like CHOCOLATE"
DOMAIN: jfh@rpp386.uucp          |             -- with my apologizes

johnson@p.cs.uiuc.edu (07/18/88)

I would think that Rationals would be the best choice for business
accounting.  They have infinite precision.  You would probably
have to write some special methods for printing, but I can't see
what else you would need.  Arithmetic on Rationals is probably
not very fast, but that is probably not important.