Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!MathWorks.Com!yeshua.marcam.com!zip.eecs.umich.edu!newsxfer.itd.umich.edu!gumby!wupost!news.utdallas.edu!corpgate!bcarh189.bnr.ca!nott!cunews!dbuck
From: dbuck@superior.carleton.ca (Dave Buck)
Subject: Re: Anything better than Float?
Message-ID: <CxLD0o.78I@cunews.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Organization: Carleton University, Ottawa, Canada
References: <37akc6$4ur$1@melbourne.dialix.oz.au> <37gn31$1815@sernews.raleigh.ibm.com>
Date: Thu, 13 Oct 1994 03:14:48 GMT
Lines: 26

In article <37gn31$1815@sernews.raleigh.ibm.com>,
Jimmy Nguyen <jimmyn@vnet.ibm.com> wrote:
>In <37akc6$4ur$1@melbourne.dialix.oz.au>, btate@melbourne.dialix.oz.au (Bradley Tate) writes:
>>...Smalltalk,
>>OTOH will give me about 7 digits of accuracy in a 4 byte representation,
>>with rounding errors every time I look around. 
>
>   With VisualAge and IBM Smalltalk, exact numbers are preserved as
>Fractions.  By default, VisualAge maps DB/2 Decimal data type to Fractions.

The only problem with using fractions to represent dollar amounts is
that they are somewhat slow.  After every operation, Smalltalk tries
to reduce the fraction by calculating a gcd: between the numerator and
the divisor.  This takes some time and isn't necessary for money.  You
are correct, however, that fractions retain the accuracy and can be
any size.


David Buck
dbuck@ccs.carleton.ca

_________________________________
| David K. Buck                 |
| dbuck@ccs.carleton.ca         |
| The Object People             |
|_______________________________|
