Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!EU.net!uunet!world!kentq
From: kentq@world.std.com (Kent J Quirk)
Subject: Re: Anything better than Float?
Message-ID: <CxL98z.GMs@world.std.com>
Organization: The World Public Access UNIX, Brookline, MA
X-Newsreader: TIN [version 1.2 PL2]
References: <37akc6$4ur$1@melbourne.dialix.oz.au>
Date: Thu, 13 Oct 1994 01:53:23 GMT
Lines: 14

The problem with using float isn't the multiply/divide, it's the "add 100 
pennies and see if you get a dollar" problem.

You really need to use integer math to keep this accurate.  I'd create a 
class that keeps track of an integer number of cents and formats like 
dollars.  If that isn't accurate enough, use an integer number of 
hundredths of cents (so you can go to .9999).

Just make sure you scale properly when you multiply or divide -- 
otherwise, it should just work.

	Kent
	kentq@world.std.com

