diff options
| author | Robert Griesemer <gri@golang.org> | 2017-03-23 10:54:08 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2017-03-23 19:43:09 +0000 |
| commit | 70ea0ec30fe37326d24249d9c9330be1ad655a90 (patch) | |
| tree | 68c929ee71004d48e0c6d45f39e3c88d68581b81 /src/math/big/float.go | |
| parent | 536a2257fba6dd18c74506988bdf3d6a15e52831 (diff) | |
| download | go-70ea0ec30fe37326d24249d9c9330be1ad655a90.tar.xz | |
math/big: replace local versions of bitLen, nlz with math/bits versions
Verified that BenchmarkBitLen time went down from 2.25 ns/op to 0.65 ns/op
an a 2.3 GHz Intel Core i7, before removing that benchmark (now covered by
math/bits benchmarks).
Change-Id: I3890bb7d1889e95b9a94bd68f0bdf06f1885adeb
Reviewed-on: https://go-review.googlesource.com/38464
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/math/big/float.go')
| -rw-r--r-- | src/math/big/float.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/math/big/float.go b/src/math/big/float.go index 6517e2063c..ac5464b127 100644 --- a/src/math/big/float.go +++ b/src/math/big/float.go @@ -14,6 +14,7 @@ package big import ( "fmt" "math" + "math/bits" ) const debugFloat = false // enable for debugging @@ -498,8 +499,8 @@ func (z *Float) setBits64(neg bool, x uint64) *Float { } // x != 0 z.form = finite - s := nlz64(x) - z.mant = z.mant.setUint64(x << s) + s := bits.LeadingZeros64(x) + z.mant = z.mant.setUint64(x << uint(s)) z.exp = int32(64 - s) // always fits if z.prec < 64 { z.round(0) |
