-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
64bit Integer #1
Comments
One problem found: node-int64 supports only signed int64. We need both signed and unsigned. |
|
0.1.18 published. |
Hey @kawanet, I'm trying to use msgpack-lite in the browser and it seems that
I'll dig into it and hopefully post a solution here. |
Do you use browserify, webpack or the pre-built version of dist/msgpack.min.js? |
I'm using webpack. |
Thanks. I check it with webpack then. It's tested with browserify but not with webpack in fact. |
It seems it works with webpack as well. Try the most recent version of the modules: npm install --save 'msgpack-lite@^0.1.18'
npm install --save 'int64-buffer@^0.1.5' # this is not needed If you still fail, please add another issue to tell your webpack config etc. |
Does this mean msgpack-lite can now encode 64 bit integers without monkey patching? |
Right. It uses int64-buffer 64bit container object. var Int64BE = require("int64-buffer").Int64BE;
var msgpack = require("msgpack-lite");
// sample big value
var bigstr = "18446744073709551615"; // 2^64-1
var bignum = parseInt(bigstr); // 18446744073709552000 (NG)
var bigbuf = new Uint64BE(bigstr);
console.warn(Uint64BE.isUint64BE(bigbuf)); // true
console.warn(bigbuf + ""); // 18446744073709551615 (OK)
// encoding
var encoded = msgpack.encode(big); // <Buffer cf ff ff ff ff ff ff ff ff>
// decoding to Double (per default)
var num = msgpack.decode(encoded);
console.warn(Uint64BE.isUint64BE(num)); // false
console.warn(num + ""); // 18446744073709552000 (NG)
// decoding to Uint64BE (with int64 codec)
var codec = msgpack.createCodec({int64: true});
var obj = msgpack.decode(encoded, {codec: codec});
console.warn(Uint64BE.isUint64BE(obj)); // true
console.warn(obj + ""); // 18446744073709551615 (OK) |
Ok, thanks. The referenced project needs to serialize 64-bit integers, which is why I was asking. |
The current decoder decodes msgpack's
int 64
(0xd3) as a JS's Number which meansdouble
.https://www.npmjs.com/package/node-int64
It looks fit for us as
node-int64
has internal rawBuffer
object with big endian byte sequence.The text was updated successfully, but these errors were encountered: