summaryrefslogtreecommitdiff
path: root/libgo/go/math/abs.go
diff options
context:
space:
mode:
Diffstat (limited to 'libgo/go/math/abs.go')
-rw-r--r--libgo/go/math/abs.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/libgo/go/math/abs.go b/libgo/go/math/abs.go
index 433d0f72737..1b7c7c1820c 100644
--- a/libgo/go/math/abs.go
+++ b/libgo/go/math/abs.go
@@ -18,10 +18,13 @@ func Abs(x float64) float64 {
}
func abs(x float64) float64 {
- switch {
- case x < 0:
+ // TODO: once golang.org/issue/13095 is fixed, change this to:
+ // return Float64frombits(Float64bits(x) &^ (1 << 63))
+ // But for now, this generates better code and can also be inlined:
+ if x < 0 {
return -x
- case x == 0:
+ }
+ if x == 0 {
return 0 // return correctly abs(-0)
}
return x