优化NumberUtil.count

This commit is contained in:
Looly 2024-10-29 20:01:21 +08:00
parent 2363e829a5
commit 30b70c7791

View File

@ -960,7 +960,8 @@ public class NumberUtil extends NumberValidator {
public static int count(final int total, final int pageSize) {
// 因为总条数除以页大小的最大余数是页大小数-1
// 因此加一个最大余数保证舍弃的余数与最大余数凑1.x就是一旦有余数则+1页
return (total + pageSize - 1) / pageSize;
// return (total + pageSize - 1) / pageSize;
return total == 0 ? 0 : (total - 1) / pageSize + 1;
}
/**