mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
优化NumberUtil.count
This commit is contained in:
@@ -960,7 +960,8 @@ public class NumberUtil extends NumberValidator {
|
|||||||
public static int count(final int total, final int pageSize) {
|
public static int count(final int total, final int pageSize) {
|
||||||
// 因为总条数除以页大小的最大余数是页大小数-1,
|
// 因为总条数除以页大小的最大余数是页大小数-1,
|
||||||
// 因此加一个最大余数,保证舍弃的余数与最大余数凑1.x,就是一旦有余数则+1页
|
// 因此加一个最大余数,保证舍弃的余数与最大余数凑1.x,就是一旦有余数则+1页
|
||||||
return (total + pageSize - 1) / pageSize;
|
// return (total + pageSize - 1) / pageSize;
|
||||||
|
return total == 0 ? 0 : (total - 1) / pageSize + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user