summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-27 16:33:01 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2012-04-27 16:33:01 +0000
commit8c1b76f80b853125403f8f5c4fc47e04eed073e6 (patch)
tree433060651508d840ce9c2e95a6d020470324ecd8 /libgo
parent70a0cfde9aa9cd92c15f717b4f7b074cf2b1eba2 (diff)
downloadgcc-8c1b76f80b853125403f8f5c4fc47e04eed073e6.tar.gz
PR go/52358
math: Work around bug in Solaris 9 implementation of ldexp. The bug is that ldexp(-1, -1075) should return -0, but the Solaris 9 implementation returns +0. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@186914 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgo')
-rw-r--r--libgo/go/math/ldexp.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/libgo/go/math/ldexp.go b/libgo/go/math/ldexp.go
index 32c9853204d..4c63edd7319 100644
--- a/libgo/go/math/ldexp.go
+++ b/libgo/go/math/ldexp.go
@@ -16,7 +16,18 @@ package math
func libc_ldexp(float64, int) float64
func Ldexp(frac float64, exp int) float64 {
- return libc_ldexp(frac, exp)
+ r := libc_ldexp(frac, exp)
+
+ // Work around a bug in the implementation of ldexp on Solaris
+ // 9. If multiplying a negative number by 2 raised to a
+ // negative exponent underflows, we want to return negative
+ // zero, but the Solaris 9 implementation returns positive
+ // zero. This workaround can be removed when and if we no
+ // longer care about Solaris 9.
+ if r == 0 && frac < 0 && exp < 0 {
+ r = Copysign(0, frac)
+ }
+ return r
}
func ldexp(frac float64, exp int) float64 {