aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2011-06-08 11:24:24 -0700
committerRobert Griesemer <gri@golang.org>2011-06-08 11:24:24 -0700
commit2de06655f1fb27bcbe61e1c091ac24448d3fe9c6 (patch)
tree5dd92dc3b1bb66544a57ee4b6ee95a4c90ed0ac9
parent636c5fac2d8bf0f7df69b2ea3cc54aeba92e70c4 (diff)
downloadgo-2de06655f1fb27bcbe61e1c091ac24448d3fe9c6.tar.gz
go-2de06655f1fb27bcbe61e1c091ac24448d3fe9c6.zip
big: removed some gratuitous +/-1's
R=mtj, bradfitz CC=golang-dev https://golang.org/cl/4584046
-rwxr-xr-xsrc/pkg/big/nat.go11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/pkg/big/nat.go b/src/pkg/big/nat.go
index ea1903b166..734568e068 100755
--- a/src/pkg/big/nat.go
+++ b/src/pkg/big/nat.go
@@ -764,13 +764,12 @@ func (x nat) string(charset string) string {
if b == b&-b {
// shift is base-b digit size in bits
shift := uint(trailingZeroBits(b)) // shift > 0 because b >= 2
- m := len(x)
mask := Word(1)<<shift - 1
w := x[0]
nbits := uint(_W) // number of unprocessed bits in w
// convert less-significant words
- for k := 0; k < m-1; k++ {
+ for k := 1; k < len(x); k++ {
// convert full digits
for nbits >= shift {
i--
@@ -782,16 +781,16 @@ func (x nat) string(charset string) string {
// convert any partial leading digit and advance to next word
if nbits == 0 {
// no partial digit remaining, just advance
- w = x[k+1]
+ w = x[k]
nbits = _W
} else {
- // partial digit in current (k) and next (k+1) word
- w |= x[k+1] << nbits
+ // partial digit in current (k-1) and next (k) word
+ w |= x[k] << nbits
i--
s[i] = charset[w&mask]
// advance
- w = x[k+1] >> (shift - nbits)
+ w = x[k] >> (shift - nbits)
nbits = _W - (shift - nbits)
}
}