You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
website/util/math.go

18 lines
196 B
Go

package util
import (
"golang.org/x/exp/constraints"
)
type Numeric interface {
constraints.Float | constraints.Integer
}
func Abs[T Numeric](a T) T {
if a < 0 {
return -a
}
return a
}