No. The final result will need to be an integer, anyway; the progress
bar accepts an integer parameter. The integer division is only a
problem because it truncates; by rearranging so the division is the last
operation, the truncation does the minimum amount of damage.
Consider the case of converting a range of 0..60 to a range of 0.100:
Start
x * 100 / 60
x * (100/60)
x * (100.0/60)
0
0
0
0.0
2
3
2
3.333 (3)
4
6
4
6.666 (6)
6
10
6
10.0
15
25
15
25.0
30
50
30
50.0
45
75
45
75.0
59
98
59
98.333 (98)
60
100
60
100.0
As you can see, the integer division produces exactly the same result as
the floating division, once it is truncated. Now, in your case, it
doesn't matter a hill of beans, because you're only doing this
computation once a second, but it might be useful to remember in the future.
···
On Thu, 27 Jul 2006 14:30:57 -0400, "John Salerno" <johnjsal@gmail.com> wrote:
That's a good point about posting it all. Next time I'll do that. And
you are right about the integer division being the problem. But even
if I remove the parentheses, wouldn't that still be a problem?
self.minutesPassed will usually, if not always, be an integer, so that
* 100 then divided by self.time would still cause the problem, right?
I just changed 100 to 100.0 and now it works.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.