20 lines
227 B
Go
20 lines
227 B
Go
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 Clamp[N Number](v, min, max N) N {
|
|
return Min(Max(v, min), max)
|
|
}
|