两个int的乘积为负

两个int的乘积为负,第1张

两个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);


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5507227.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-12-13
下一篇2022-12-13

发表评论

登录后才能评论

评论列表(0条)

    保存