Thanks Fred. I did things in pennies and it worked.<div>-Amit</div><div><br><br><div class="gmail_quote">On Wed, Nov 23, 2011 at 9:48 AM, Fred Morris <span dir="ltr"><<a href="mailto:m3047@m3047.net">m3047@m3047.net</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">On Wednesday 23 November 2011 10:24, Amit Sett wrote:<br>
> [...] The program works well except for some cases where it short<br>
> changes a customer by 1 penny [...]<br>
<br>
Try doing things in pennies, e.g. a dollar is 100 pennies.<br>
<br>
Do you know what a repeating decimal is, and do you know what causes them?<br>
Basically any time you divide 1 by a prime number not in your number base you<br>
get a repeating decimal.<br>
<br>
For instance in base 10 (2 * 5) if you divide by 3, 7, 11, 13, etc. you get a<br>
repeating decimal.<br>
<br>
In base 2, dividing by 3, 5, 7, 11, etc does the same thing. If you divide by<br>
100 (2 * 2 * 5 * 5) you get a repeating decimal, or in other words there is<br>
rounding error.<br>
<br>
ObMathNote: 0.9999999... actually is provably equal to 1. ;-)<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
<br>
Fred<br>
<br>
_____________________________________________________________<br>
Seattle Perl Users Group Mailing List<br>
     POST TO: <a href="mailto:spug-list@pm.org">spug-list@pm.org</a><br>
SUBSCRIPTION: <a href="http://mail.pm.org/mailman/listinfo/spug-list" target="_blank">http://mail.pm.org/mailman/listinfo/spug-list</a><br>
    MEETINGS: 3rd Tuesdays<br>
    WEB PAGE: <a href="http://seattleperl.org/" target="_blank">http://seattleperl.org/</a><br>
</font></span></blockquote></div><br></div>