mirror of https://github.com/golang/go.git
math: fix normalization bug in pure-Go sqrt
Fixes #13013 Change-Id: I6cf500eacdce76e303fc1cd92dd1c80eef0986bc Reviewed-on: https://go-review.googlesource.com/16158 Reviewed-by: Andrew Gerrand <adg@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
8ee0fd8623
commit
22d4c8bf13
|
|
@ -1363,7 +1363,7 @@ var vfmodfSC = []float64{
|
|||
var modfSC = [][2]float64{
|
||||
{Inf(-1), NaN()}, // [2]float64{Copysign(0, -1), Inf(-1)},
|
||||
{Copysign(0, -1), Copysign(0, -1)},
|
||||
{Inf(1), NaN()}, // [2]float64{0, Inf(1)},
|
||||
{Inf(1), NaN()}, // [2]float64{0, Inf(1)},
|
||||
{NaN(), NaN()},
|
||||
}
|
||||
|
||||
|
|
@ -1611,6 +1611,7 @@ var vfsqrtSC = []float64{
|
|||
0,
|
||||
Inf(1),
|
||||
NaN(),
|
||||
Float64frombits(2), // subnormal; see https://golang.org/issue/13013
|
||||
}
|
||||
var sqrtSC = []float64{
|
||||
NaN(),
|
||||
|
|
@ -1619,6 +1620,7 @@ var sqrtSC = []float64{
|
|||
0,
|
||||
Inf(1),
|
||||
NaN(),
|
||||
3.1434555694052576e-162,
|
||||
}
|
||||
|
||||
var vftanhSC = []float64{
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ func sqrt(x float64) float64 {
|
|||
// normalize x
|
||||
exp := int((ix >> shift) & mask)
|
||||
if exp == 0 { // subnormal x
|
||||
for ix&1<<shift == 0 {
|
||||
for ix&(1<<shift) == 0 {
|
||||
ix <<= 1
|
||||
exp--
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue