A good checkbook acct. program

M.J.Shannon mjs at sfsup.UUCP
Sat Feb 8 16:11:11 AEST 1986


> I was using this checkbook program as an example in a course, plugged in some
> realistic numbers, and found it was coming up off by a cent, then two cents
> a bit later...  What I found was that 'awk' on this system was using floats
> for all the real values, rather than doubles.
> 
> For instance: % awk 'BEGIN {printf "%f\n", 12345.67 ; exit}'
> 12345.669922
> 
> As this is off by .008 of a cent, after 125 of these you get close to losing
> a penny.  Of course some representations will be over, and some under,
> but do you really want to trust your balance to fate?
> 
> Andrew Burt
> isis!aburt   or   aburt at udenver.csnet

But all banks use fixed point arithmetic.  This has the advantage of
being almost as fast as integer arithmetic, as well as preventing
representation/roundoff errors.  If you change the semantics of your
program to store cents (rather than dollars), you can probably eliminate
such errors (unless awk uses float/double for all numeric ops).

	Marty Shannon
	AT&T-IS Computer Systems
	(201)-522-6063



More information about the Comp.sources.bugs mailing list