参见http://en.wikipedia.org/wiki/Arithmetic_overflow
要在Java中修复,请尝试使用a long
代替。
int progress = (int) ((byte_counter * 100L) / size);
或相反的操作顺序
int progress = (int) (((float) byte_counter) / size) * 100);
两个int的乘积为负
参见http://en.wikipedia.org/wiki/Arithmetic_overflow
要在Java中修复,请尝试使用a long
代替。
int progress = (int) ((byte_counter * 100L) / size);
或相反的操作顺序
int progress = (int) (((float) byte_counter) / size) * 100);