From d598fb5ce5eb781b51d7ecff59253f4b3753281a Mon Sep 17 00:00:00 2001 From: xing Date: Sun, 23 Jun 2024 21:30:57 +0800 Subject: [PATCH] add some func --- helper/number/number.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helper/number/number.go b/helper/number/number.go index b857afc..aefb670 100644 --- a/helper/number/number.go +++ b/helper/number/number.go @@ -100,6 +100,10 @@ func Divide[T constraints.Integer | constraints.Float](i, j T) T { return i / j } +func Ceil[T constraints.Integer](num1, num2 T) int { + return int((num1 + num2 - 1) / num2) +} + func DivideCeil[T constraints.Integer](num1, num2 T) T { return T(math.Ceil(float64(num1) / float64(num2))) }