aboutsummaryrefslogtreecommitdiff
path: root/src/math/big/floatconv_test.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2017-03-23 10:54:08 -0700
committerRobert Griesemer <gri@golang.org>2017-03-23 19:43:09 +0000
commit70ea0ec30fe37326d24249d9c9330be1ad655a90 (patch)
tree68c929ee71004d48e0c6d45f39e3c88d68581b81 /src/math/big/floatconv_test.go
parent536a2257fba6dd18c74506988bdf3d6a15e52831 (diff)
downloadgo-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/floatconv_test.go')
-rw-r--r--src/math/big/floatconv_test.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/math/big/floatconv_test.go b/src/math/big/floatconv_test.go
index 9911280abc..6d0f17dbe0 100644
--- a/src/math/big/floatconv_test.go
+++ b/src/math/big/floatconv_test.go
@@ -8,6 +8,7 @@ import (
"bytes"
"fmt"
"math"
+ "math/bits"
"strconv"
"testing"
)
@@ -328,9 +329,9 @@ func TestFloat64Text(t *testing.T) {
// actualPrec returns the number of actually used mantissa bits.
func actualPrec(x float64) uint {
- if bits := math.Float64bits(x); x != 0 && bits&(0x7ff<<52) == 0 {
+ if mant := math.Float64bits(x); x != 0 && mant&(0x7ff<<52) == 0 {
// x is denormalized
- return 64 - nlz64(bits&(1<<52-1))
+ return 64 - uint(bits.LeadingZeros64(mant&(1<<52-1)))
}
return 53
}