abs.go 205 B

12345678910
  1. package math32
  2. // Abs returns the absolute value of x.
  3. //
  4. // Special cases are:
  5. // Abs(±Inf) = +Inf
  6. // Abs(NaN) = NaN
  7. func Abs(x float32) float32 {
  8. return Float32frombits(Float32bits(x) &^ (1 << 31))
  9. }