Commit a171ac03 by Ian Lance Taylor

compiler: handle >32bit exponent in Ldexp

    
    Libgo's implementation of math.Ldexp declared the libc "ldexp" as
    taking an 'int' exponent argument, which is not quite right for 64-bit
    platforms (exp arg is always int32); this could yield incorrect
    results for exponent values outside the range of Minint32/Maxint32.
    Fix by upating the type for the libc version of ldexp, and adding
    guards to screen for out-of-range exponents.
    
    Fixes #21323.
    
    Reviewed-on: https://go-review.googlesource.com/54250

From-SVN: r250992
parent 0ca970cd
db685a1a9aa8b3b916dd6d1284895e01d73158e1 5fd112e5c2968e94761c41519c451d789e23a92b
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -13,10 +13,15 @@ package math ...@@ -13,10 +13,15 @@ package math
// Ldexp(NaN, exp) = NaN // Ldexp(NaN, exp) = NaN
//extern ldexp //extern ldexp
func libc_ldexp(float64, int) float64 func libc_ldexp(float64, int32) float64
func Ldexp(frac float64, exp int) float64 { func Ldexp(frac float64, exp int) float64 {
r := libc_ldexp(frac, exp) if exp > MaxInt32 {
exp = MaxInt32
} else if exp < MinInt32 {
exp = MinInt32
}
r := libc_ldexp(frac, int32(exp))
return r return r
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment