From: Russ Cox Date: Fri, 16 Jan 2015 19:33:27 +0000 (-0500) Subject: runtime: rename float64 constants to avoid name space pollution X-Git-Tag: go1.5beta1~2314 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7ef59e4ed8c2bc4d79d1a40ece6e262677214ace;p=gostls13.git runtime: rename float64 constants to avoid name space pollution Otherwise, if you mistakenly refer to an undeclared 'shift' variable, you get 52. Change-Id: I845fb29f23baee1d8e17b37bde0239872eb54316 Reviewed-on: https://go-review.googlesource.com/2909 Reviewed-by: Austin Clements --- diff --git a/src/runtime/sqrt.go b/src/runtime/sqrt.go index e3a27014b5..d483f8a01f 100644 --- a/src/runtime/sqrt.go +++ b/src/runtime/sqrt.go @@ -86,10 +86,10 @@ import "unsafe" // Notes: Rounding mode detection omitted. const ( - mask = 0x7FF - shift = 64 - 11 - 1 - bias = 1023 - maxFloat64 = 1.797693134862315708145274237317043567981e+308 // 2**1023 * (2**53 - 1) / 2**52 + float64Mask = 0x7FF + float64Shift = 64 - 11 - 1 + float64Bias = 1023 + maxFloat64 = 1.797693134862315708145274237317043567981e+308 // 2**1023 * (2**53 - 1) / 2**52 ) func float64bits(f float64) uint64 { return *(*uint64)(unsafe.Pointer(&f)) } @@ -105,25 +105,25 @@ func sqrt(x float64) float64 { } ix := float64bits(x) // normalize x - exp := int((ix >> shift) & mask) + exp := int((ix >> float64Shift) & float64Mask) if exp == 0 { // subnormal x - for ix&1<>= 1 // exp = exp/2, exponent of square root // generate sqrt(x) bit by bit ix <<= 1 - var q, s uint64 // q = sqrt(x) - r := uint64(1 << (shift + 1)) // r = moving bit from MSB to LSB + var q, s uint64 // q = sqrt(x) + r := uint64(1 << (float64Shift + 1)) // r = moving bit from MSB to LSB for r != 0 { t := s + r if t <= ix { @@ -138,6 +138,6 @@ func sqrt(x float64) float64 { if ix != 0 { // remainder, result not exact q += q & 1 // round according to extra bit } - ix = q>>1 + uint64(exp-1+bias)<>1 + uint64(exp-1+float64Bias)<