您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

两个int的乘积为负

两个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);
其他 2022/1/1 18:53:31 有495人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶