I'm probably going to get bit for this since it doesn't directly answer your question, however I think it needs to be noted.
I wouldn't worry about questioning the question that much -- I think it's valuable feedback to the OP.
You should avoid using a float (decimal) to control a loop. Basically, it boils down to what you're seeing there when the control for the loop does something unexpected. It's just good practice to avoid it since many languages suffer from this sort of thing.
Your meaning is a little murky here, but if I can clarify, adding an increment that contains 'a little error' means you can end up with 'a significant error' after a 'sufficiently large' number of times through the loop.
Another way to put it comes from my Dad, who did IBM 370 assembler and COBOL from back in the 60s -- If you test for equality with '6.0' but your loop counter actually contains '5.99999999', your loop is either going to continue forever or go one loop too far.
Is it fair to stick a link to my site here?
Sure. Just try to make your .sig 'smallish' when displayed on the site. A one or two line post followed by an eight line .sig looks kinda silly. :)
Sure thing. We're all here to learn and help each other; I'm just trying to return the favour and dodge the occasional flaming arrow.
--t. alex
Life is short: get busy!
|