SPUG: Rounding error

michaelrwolf at att.net michaelrwolf at att.net
Wed Nov 23 19:49:49 PST 2011

Heck, there's been more than 500% inflation since the penny was useful.  Do it 
in nickels.  Or dimes.


My personal opinion (worth 2 of the things I think are useless) is that the 
penny should have gone the way of the lira when the dollar coin came out, and do 
a hardware register shift right (register as in cash register), leaving the 
nickel as the smallest coin in the till.

Heck, they should have done it twice, and gotten a $2 coin (or $5), and done 
away with the nickel.

It was interesting (to my penny-ante-mind) how they made change in Italy (30 
years ago) when they still had the lira.  It was difficult to get a 50 lira bill 
that was structurally sound enough to hold itself together so most transactions 
rounded to 100-ish lira.  Mas o minas, to go polyglot on you.  All this 
US-anal-retentive-penny-retentive accounting is a waste of time, and time is 

Riddle me this, joker... 

If it takes you more than a penny's time to account for a penny, what's that 



Hope the "don't use fractions" design pattern helped.  My rant was independent 
of that.  I really *do* hope that you're dealing with a business where the more 
important aspect is do you have enough bits to hold that many pennies!

 Michael R. Wolf
____MichaelRWolf at att.net
________All mammals learn by playing.

From: Amit Sett <amitsett at gmail.com>
To: Fred Morris <m3047 at m3047.net>
Cc: SPUG <spug-list at pm.org>
Sent: Wed, November 23, 2011 10:10:14 AM
Subject: Re: SPUG: Rounding error

Thanks Fred. I did things in pennies and it worked.

On Wed, Nov 23, 2011 at 9:48 AM, Fred Morris <m3047 at m3047.net> wrote:

On Wednesday 23 November 2011 10:24, Amit Sett wrote:
>> [...] The program works well except for some cases where it short
>> changes a customer by 1 penny [...]
>Try doing things in pennies, e.g. a dollar is 100 pennies.
>Do you know what a repeating decimal is, and do you know what causes them?
>Basically any time you divide 1 by a prime number not in your number base you
>get a repeating decimal.
>For instance in base 10 (2 * 5) if you divide by 3, 7, 11, 13, etc. you get a
>repeating decimal.
>In base 2, dividing by 3, 5, 7, 11, etc does the same thing. If you divide by
>100 (2 * 2 * 5 * 5) you get a repeating decimal, or in other words there is
>rounding error.
>ObMathNote: 0.9999999... actually is provably equal to 1. ;-)
>Seattle Perl Users Group Mailing List
>    POST TO: spug-list at pm.org
>SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>   MEETINGS: 3rd Tuesdays
>   WEB PAGE: http://seattleperl.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/spug-list/attachments/20111123/40b178a9/attachment.html>

More information about the spug-list mailing list