Currently I’m having a problem, that drives me crazy.
You know, how the percentage is calculated.
It’s (p/pMax)*100 , isn’t it ?
That is just that, what I’ve written in code.
But I ALWAYS getting 0.0 as the result of this calculation.
See the screenshot for clarifying.
As you can see the float variable prg becomes 0.0 as the result of the calculation (252/1944)*100
What am I doing wrong ?
If you want, I can put the variable initialization here.
Thanks for helping !
252/1944 is treated as an int division even though you are putting the result in a double.
Try 252.0/1944.0
In the case of variables, just cast them as doubles or floats
(e.g. (double) a / (double) b )
LE: I should clarify that, like the others have pointed out, you only need to cast one of the two variables in the operation as a float/double for that to work.