]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: copy sqrt normalization bugfix from math
authorCaleb Spare <cespare@gmail.com>
Fri, 23 Oct 2015 21:49:56 +0000 (14:49 -0700)
committerMinux Ma <minux@golang.org>
Fri, 23 Oct 2015 23:43:47 +0000 (23:43 +0000)
This copies the change from CL 16158 (applied as
22d4c8bf13d5edf4670dbdaf0854d653d9c2b81a).

Updates #13013

Change-Id: Id7d02e63d92806f06a4e064a91b2fb6574fe385f
Reviewed-on: https://go-review.googlesource.com/16291
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Minux Ma <minux@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/sqrt.go
src/runtime/sqrt_test.go

index 7452a61f3cdcc2e042d9fb99e2d6992723bc5621..1b130e3b019db5e11474a8ad8e400f6eb9ce6dd8 100644 (file)
@@ -117,7 +117,7 @@ func sqrt(ix uint64) uint64 {
        // normalize x
        exp := int((ix >> float64Shift) & float64Mask)
        if exp == 0 { // subnormal x
-               for ix&1<<float64Shift == 0 {
+               for ix&(1<<float64Shift) == 0 {
                        ix <<= 1
                        exp--
                }
index d5ccc7fb1d7e0496a81b0f672e24e69d5949afa3..54539e1e2e4e9c443ffed8520f657eb77f703cc7 100644 (file)
@@ -74,6 +74,7 @@ var vfsqrtSC = []float64{
        0,
        math.Inf(1),
        math.NaN(),
+       math.Float64frombits(2),
 }
 var sqrtSC = []float64{
        math.NaN(),
@@ -82,4 +83,5 @@ var sqrtSC = []float64{
        0,
        math.Inf(1),
        math.NaN(),
+       3.1434555694052576e-162,
 }