github.com/songzhibin97/go-baseutils@v0.0.2-0.20240302024150-487d8ce9c082/base/bmath/abs.go (about) 1 package bmath 2 3 import "github.com/songzhibin97/go-baseutils/base/btype" 4 5 func Abs[T btype.Integer | btype.Float](a T) T { 6 if a > 0 { 7 return a 8 } 9 return -a 10 }