1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
Files
go-mixed/mathx/int.go
2022-04-07 10:30:12 +08:00

17 lines
356 B
Go

package mathx
import (
"github.com/charlienet/go-mixed/expr"
"golang.org/x/exp/constraints"
)
// MaxInt returns the larger one of v1 and v2.
func Max[T constraints.Ordered](v1, v2 T) T {
return expr.If(v1 > v2, v1, v2)
}
// MinInt returns the smaller one of v1 and v2.
func Min[T constraints.Ordered](v1, v2 T) T {
return expr.If(v1 < v2, v1, v2)
}