A good checkbook acct. program

Andrew Burt aburt at isis.UUCP
Fri Feb 7 00:43:02 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, a Pyramid 90x with
OSx 2.5, and on a pure 4.2 system also, were using floats for all the real
values, rather than doubles.  With balances like $12345.67 we were hitting the
limits of float representation, and getting 1/100 cent errors or so which
eventually turned into 1 cent errors... I recompiled awk with doubles in
awk.def, and not only did this of course go away, but awk ran faster at it.

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?  This showed up when
a bank balance and a current balance disagreed by a cent.  Though it shouldn't
be a problem over a month, unless you write hundreds of checks, it makes it
useless to keep entire years in one book.

Anyone have any clues why floats are still used in awk rather than doubles?

Now, are you SURE your bank was wrong...?

				Andrew
-- 

Andrew Burt
isis!aburt   or   aburt at udenver.csnet



More information about the Comp.sources.bugs mailing list