[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 08:30:44 PDT 2009


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.

xoxo,
Adny

--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance






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