mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
优化NumberUtil.count
This commit is contained in:
parent
2363e829a5
commit
30b70c7791
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user