| Author |
Providing feedback when processing a large for loop
|
Mark Waes
Greenhorn
Joined: Aug 06, 2008
Posts: 21
|
|
Hi,
This should be easy, but for the life of me I can't figure it out...
I'm looking to provide user feeback when processing a large for-loop, and at each 10% milestone, print the message '10% Complete', '20% Complete' etc..
my code is below, but it suffers from a problem when the countTarget instance variable is an odd number (prime numbers being a specific example) in that not all of the 10% milestones are printed.
Regardless of the number of interations required by the for-loop, I would like to print feedback 10 times.
Any help gratefully received...
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9948
|
|
the problem is you're using floats here, and floating point arithmetic is never precise. What i'd probably do is something like
You may not get your output at EXACTLY 10%, but pretty dang close.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
 |
|
|
subject: Providing feedback when processing a large for loop
|
|
|