Skip to content

Commit

Permalink
The top bit of bytes be nonzero, but nevertheless wants unsigned data
Browse files Browse the repository at this point in the history
  • Loading branch information
kisonecat committed Nov 1, 2017
1 parent 5bd3acf commit 3937962
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions bubble_babble.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ var encode = function(input, encoding) {

// create full tuples
for (i = 0; i + 1 < len; i += 2) {
byte1 = input.readInt8(i);
byte1 = input.readUInt8(i);
result += odd_partial(byte1, checksum);

byte2 = input.readInt8(i + 1);
byte2 = input.readUInt8(i + 1);
d = (byte2 >> 4) & 15;
e = byte2 & 15;

Expand All @@ -28,7 +28,7 @@ var encode = function(input, encoding) {

// handle partial tuple
if (i < len) {
byte1 = input.readInt8(i);
byte1 = input.readUInt8(i);
result += odd_partial(byte1, checksum);
} else {
result += even_partial(checksum);
Expand Down Expand Up @@ -122,6 +122,7 @@ var decode_2part_byte = function(d, e) {
}

var next_checksum = function(checksum, byte1, byte2) {

return ((checksum * 5) + (byte1 * 7) + byte2) % 36;
}

Expand Down

0 comments on commit 3937962

Please sign in to comment.