diff --git a/lib/decoder.js b/lib/decoder.js index be6c00d..8df204b 100644 --- a/lib/decoder.js +++ b/lib/decoder.js @@ -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) diff --git a/lib/encoder.js b/lib/encoder.js index 59a1ad8..7ed9fa4 100644 --- a/lib/encoder.js +++ b/lib/encoder.js @@ -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) { diff --git a/test/5-bits-negative-integers.js b/test/5-bits-negative-integers.js index f12e737..077f4ef 100644 --- a/test/5-bits-negative-integers.js +++ b/test/5-bits-negative-integers.js @@ -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) } diff --git a/test/8-bits-signed-integers.js b/test/8-bits-signed-integers.js index f0d26e5..21e667c 100644 --- a/test/8-bits-signed-integers.js +++ b/test/8-bits-signed-integers.js @@ -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) }