mirror of
https://github.com/jefferyjob/go-easy-utils.git
synced 2025-10-05 15:06:50 +08:00
18 lines
303 B
Go
18 lines
303 B
Go
package mathUtil
|
|
|
|
import (
|
|
"math"
|
|
"reflect"
|
|
)
|
|
|
|
// Ceil 对float数据向上取整
|
|
func Ceil[T float32 | float64](num T) int {
|
|
switch reflect.ValueOf(num).Kind() {
|
|
case reflect.Float32:
|
|
return int(math.Ceil(float64(num)))
|
|
case reflect.Float64:
|
|
return int(math.Ceil(float64(num)))
|
|
}
|
|
return 0
|
|
}
|