Skip to content
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

Unable to pack int 64 #183

Open
SamuelZon258 opened this issue Jun 17, 2021 · 1 comment
Open

Unable to pack int 64 #183

SamuelZon258 opened this issue Jun 17, 2021 · 1 comment

Comments

@SamuelZon258
Copy link

SamuelZon258 commented Jun 17, 2021

Hello, when I packaged "number", I could not package "int64". After I checked the source code, I changed "Number.isSafeInteger(object)" to "object.toString().indexOf('.') <0" It is temporarily solved. Obviously this is not the best method, but it can temporarily solve my problem. If there is a better solution to identify ”int64“, I hope to inform, thanks

@gfx
Copy link
Member

gfx commented Jun 18, 2021

This is because there's no int64 in JavaScript. A number that Number.isSafeInteger() returns false is NOT a precise integer (or not a "safe" integer) so that you should not deal it as integers but instead it is a floating point number.

If you need larger integers than "safe" integers, you have to use bigint. There's no direct support for bigint right now, but you can easily handle it. Seel https://github.com/msgpack/msgpack-javascript#handling-bigint-with-extensioncodec for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants