Feature/math util (#22)

Development supports the math package
This commit is contained in:
jeffery
2023-04-12 11:10:07 +08:00
committed by GitHub
parent 9a8c60b30a
commit f97913a2bc
30 changed files with 501 additions and 71 deletions

17
mathUtil/floor.go Normal file
View File

@@ -0,0 +1,17 @@
package mathUtil
import (
"math"
"reflect"
)
// Floor 对float数据向下取整
func Floor[T float32 | float64](num T) int {
switch reflect.ValueOf(num).Kind() {
case reflect.Float32:
return int(math.Floor(float64(num)))
case reflect.Float64:
return int(math.Floor(float64(num)))
}
return 0
}