Files
go-easy-utils/mathUtil/ceil.go
jeffery f97913a2bc Feature/math util (#22)
Development supports the math package
2023-04-12 11:10:07 +08:00

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
}