github.com/rajveermalviya/gamen@v0.1.2-0.20220930195403-9be15877c1aa/internal/common/mathx/mathx.go (about) 1 package mathx 2 3 import ( 4 "math" 5 6 "golang.org/x/exp/constraints" 7 ) 8 9 func Min[T constraints.Integer | constraints.Float](a, b T) T { 10 return T(math.Min(float64(a), float64(b))) 11 } 12 13 func Max[T constraints.Integer | constraints.Float](a, b T) T { 14 return T(math.Max(float64(a), float64(b))) 15 } 16 17 func Abs[T constraints.Integer | constraints.Float](a T) T { 18 return T(math.Abs(float64(a))) 19 }