diff options
| author | Caleb Spare <cespare@gmail.com> | 2015-10-23 14:49:56 -0700 |
|---|---|---|
| committer | Minux Ma <minux@golang.org> | 2015-10-23 23:43:47 +0000 |
| commit | fb7178e7cc219062efe7d5da5df4f85b01b0f8ac (patch) | |
| tree | b46771d51421891f5e407e08ff967b4b6237278a /src | |
| parent | 75a423a983366f92eebe12cf6875e1ffc07537ec (diff) | |
| download | go-fb7178e7cc219062efe7d5da5df4f85b01b0f8ac.tar.xz | |
runtime: copy sqrt normalization bugfix from math
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>
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/sqrt.go | 2 | ||||
| -rw-r--r-- | src/runtime/sqrt_test.go | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/sqrt.go b/src/runtime/sqrt.go index 7452a61f3c..1b130e3b01 100644 --- a/src/runtime/sqrt.go +++ b/src/runtime/sqrt.go @@ -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-- } diff --git a/src/runtime/sqrt_test.go b/src/runtime/sqrt_test.go index d5ccc7fb1d..54539e1e2e 100644 --- a/src/runtime/sqrt_test.go +++ b/src/runtime/sqrt_test.go @@ -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, } |
