gmath/limits.go

20 lines
227 B
Go
Raw Normal View History

2022-08-16 12:23:03 +02:00
package gmath
func Min[N Number](a, b N) N {
if a < b {
return a
}
return b
}
func Max[N Number](a, b N) N {
if a > b {
return a
}
return b
}
func Limit[N Number](v, min, max N) N {
return Min(Max(v, min), max)
}