add some func

This commit is contained in:
xing 2024-06-23 21:30:57 +08:00
parent 63f769796f
commit d598fb5ce5

View File

@ -100,6 +100,10 @@ func Divide[T constraints.Integer | constraints.Float](i, j T) T {
return i / j 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 { func DivideCeil[T constraints.Integer](num1, num2 T) T {
return T(math.Ceil(float64(num1) / float64(num2))) return T(math.Ceil(float64(num1) / float64(num2)))
} }