1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 00:22:41 +08:00
This commit is contained in:
2022-11-16 17:31:28 +08:00
parent ac346274c1
commit abe445f5e6
6 changed files with 486 additions and 5 deletions

View File

@ -7,17 +7,15 @@ import (
// 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)
return expr.Ternary(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)
return expr.Ternary(v1 < v2, v1, v2)
}
func abs(n int64) int64 {
func Abs(n int64) int64 {
y := n >> 63
return (n ^ y) - y
}