Skip to content

Commit

Permalink
fix abs for new golang
Browse files Browse the repository at this point in the history
  • Loading branch information
docmerlin committed Apr 12, 2018
1 parent d1e7b22 commit a0761be
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions abs.go
Expand Up @@ -6,14 +6,5 @@ package math32
// Abs(±Inf) = +Inf
// Abs(NaN) = NaN
func Abs(x float32) float32 {
if x < 0 {
return -x
}
if x == 0 {
return 0 // return correctly abs(-0)
}
return x

// asUint := Float32bits(x) & uint32(0x7FFFFFFF)
// return Float32frombits(asUint)
return Float32frombits(Float32bits(x) &^ (1 << 31))
}

0 comments on commit a0761be

Please sign in to comment.