-
Notifications
You must be signed in to change notification settings - Fork 103
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
handling big integers #44
Comments
I'm not sure... I would probably use something like https://github.com/indutny/bn.js to handle big numbers, but I wouldn't want to pull in such a big dependency for a rare use case like this. Perhaps we could do away with just mentioning this in docs and providing a JS workaround in a gist? |
Out of scope for this library for now, keeping it simple. |
Now that Node.js 10.4+ supports BigInt any chance of revisiting support for this? I'm working with a 3rd party service that unfortunately using int64 to send IDs which doesn't work well trying to stuff into a 32 bit JavaScript int. |
In order to be backward compatible, it might be worth looking at: JS_NORMAL would be the current behavior. The way compiler would need to make calls to the new functions writeVarintFromBigint / writeVarintFromString / readVarintFromBigint / readVarintFromString. writeVarintFromString and readVarintFromString could be implemented by calling the Bigint variant and doing a toString value of it. |
As of now this library handles integers over 2^53 as numbers which causes them to loose precision. The safer way would be to convert them to strings or buffers. Do you plan to add this to this package? In our project we extend your library to handle varint64 in this way, do you need a pull request with the similar implementation?
The text was updated successfully, but these errors were encountered: