From d0bf70f6a8f750ba2fa3f3988bab30780cb60982 Mon Sep 17 00:00:00 2001 From: Pluto <30676110+Pluto-Whong@users.noreply.github.com> Date: Mon, 21 Oct 2024 17:34:21 +0800 Subject: [PATCH] Update NumberUtil.java MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化统计方法 至少三次除法 -> 至多三次加减法+一次除法 --- hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java b/hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java index 8c9c1cd02..a49b425c4 100755 --- a/hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/util/NumberUtil.java @@ -2297,7 +2297,7 @@ public class NumberUtil { * @since 3.0.6 */ 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; } /**