mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
Update NumberUtil.java
优化统计方法 至少三次除法 -> 至多三次加减法+一次除法
This commit is contained in:
parent
467d67e83a
commit
d0bf70f6a8
@ -2297,7 +2297,7 @@ public class NumberUtil {
|
|||||||
* @since 3.0.6
|
* @since 3.0.6
|
||||||
*/
|
*/
|
||||||
public static int count(int total, int part) {
|
public static int count(int total, int part) {
|
||||||
return (total % part == 0) ? (total / part) : (total / part + 1);
|
return total == 0 ? 0 : (total - 1) / part + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user