Skip to content

Commit

Permalink
Merge pull request #22 from andy-trimble/master
Browse files Browse the repository at this point in the history
Fixed a bug where the value of 0xe0 would not parse correctly.
  • Loading branch information
mcollina committed May 22, 2015
2 parents 43b5627 + c61e6e6 commit dbc4f0c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/decoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ module.exports = function buildDecode(decodingTypes) {
} else {
return null
}
} else if (first > 0xe0) {
} else if (first >= 0xe0) {
// 5 bits negative ints
result = first - 0x100
return buildDecodeResult(result, 1)
Expand Down
2 changes: 1 addition & 1 deletion lib/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ module.exports = function buildEncode(encodingTypes) {
write64BitUint(buf, obj)
}
} else {
if (obj > -32) {
if (obj >= -32) {
buf = new Buffer(1)
buf[0] = 0x100 + obj
} else if (obj >= -128) {
Expand Down
2 changes: 1 addition & 1 deletion test/5-bits-negative-integers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test('encoding/decoding 5-bits negative ints', function(t) {
, allNum = []
, i

for (i = 1; i < 32; i++) {
for (i = 1; i <= 32; i++) {
allNum.push(-i)
}

Expand Down
2 changes: 1 addition & 1 deletion test/8-bits-signed-integers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ test('encoding/decoding 8-bits big-endian signed integers', function(t) {
, allNum = []
, i

for (i = 32; i <= 128; i++) {
for (i = 33; i <= 128; i++) {
allNum.push(-i)
}

Expand Down

0 comments on commit dbc4f0c

Please sign in to comment.