Skip to content

Commit

Permalink
bs58: simplify carry logic
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Jul 24, 2014
1 parent dede3a7 commit fd805f7
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/bs58.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ function encode(buffer) {
}

while (carry) {
digits.push(carry)
digits.push(carry % BASE)

carry = (digits[digits.length - 1] / BASE) | 0
digits[digits.length - 1] %= BASE
carry = (carry / BASE) | 0
}
}

Expand Down Expand Up @@ -67,10 +66,9 @@ function decode(string) {
}

while (carry) {
bytes.push(carry)
bytes.push(carry & 0xff)

carry = bytes[bytes.length - 1] >> 8
bytes[bytes.length - 1] &= 0xff
carry >>= 8
}
}

Expand Down

0 comments on commit fd805f7

Please sign in to comment.