I\'m currently coding a little download manager and I get a funny output when I try to calculate the download-progress in percent. This is what i use to calculate it:
See http://en.wikipedia.org/wiki/Arithmetic_overflow
To fix in java, try using a long instead.
long
int progress = (int) ((byte_counter * 100L) / size);
or reverse order of operations
int progress = (int) (((float) byte_counter) / size) * 100);