From: ian Date: Fri, 27 Apr 2012 16:32:42 +0000 (+0000) Subject: PR go/52358 X-Git-Tag: upstream/4.9.2~13007 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ff40a6bf4310e9e5bb398be2e590e3998fb203a;p=platform%2Fupstream%2Flinaro-gcc.git 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/trunk@186913 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/libgo/go/math/ldexp.go b/libgo/go/math/ldexp.go index 32c9853..4c63edd 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 {