xyosc/vendor/github.com/chewxy/math32/abs.go
2024-12-21 17:38:26 +01:00

11 lines
205 B
Go

package math32
// Abs returns the absolute value of x.
//
// Special cases are:
// Abs(±Inf) = +Inf
// Abs(NaN) = NaN
func Abs(x float32) float32 {
return Float32frombits(Float32bits(x) &^ (1 << 31))
}