[grand-rapids-pm-list] Second grade math is giving me problems

grand-rapids-pm-list at pm.org grand-rapids-pm-list at pm.org
Tue Mar 10 11:03:46 PDT 2009


On Mar 10, 2009, at 11:30 AM, grand-rapids-pm-list at pm.org wrote:

>
> On Mar 10, 2009, at 10:18 AM, grand-rapids-pm-list at pm.org wrote:
>
>> I suspect running this code through your perl interpreter would  
>> give you the same results. I'm convinced the problem is something  
>> simple, but I just don't see it. Anyone have any ideas?
>
>
> It's just the nature of floating-point numbers.  Your last total is  
> effectively zero, but it's a very very small number, so is not zero.
>
> What you may want to do is do integer arithmetic, and treat $7.14 as  
> 714 pennies.  Then you won't have these floating point problems.

Had to run out. Just reading this now.

Thanks for the response. Got it working.

Funny that i don't recall ever having this problem in the past. Maybe  
i don't do as much floating point arithmetic as I thought. Or maybe I  
never caught it ... :-/

- brian


More information about the grand-rapids-pm-list mailing list