Skip to content

Commit

Permalink
Merge pull request #37 from sgerace/issue-36
Browse files Browse the repository at this point in the history
Fix maximum uint32 value (4294967295) being encoded as uint64
  • Loading branch information
mcollina committed Oct 13, 2015
2 parents 5b8a36d + 730f939 commit fd1b326
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/encoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ module.exports = function buildEncode(encodingTypes, forceFloat64) {
buf = new Buffer(3)
buf[0] = 0xcd
buf.writeUInt16BE(obj, 1)
} else if (obj < 0xffffffff) {
} else if (obj <= 0xffffffff) {
buf = new Buffer(5)
buf[0] = 0xce
buf.writeUInt32BE(obj, 1)
Expand Down
1 change: 1 addition & 0 deletions test/32-bits-unsigned-integers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ test('encoding/decoding 32-bits big-endian unsigned integers', function(t) {
}

allNum.push(0xfffffffe)
allNum.push(0xffffffff)

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

allNum.push(0xffffffff)
allNum.push(0x0000000100000000)

allNum.push(0xffffffffeeeee)

Expand Down

0 comments on commit fd1b326

Please sign in to comment.