-
Notifications
You must be signed in to change notification settings - Fork 11
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
falsely deserialization for big numbers #57
Comments
I realized now that the lib only supports 32 bits numbers. that unfortunate :( |
Is called RoaringBitmap32 for a reason. 32 bit unsigned integers. Roaring bitmap data structure is 32 bits by design. CRoaring C++ version supports a type of bitmap that can store 64 bits by creating up to 4 billion bitmaps for the higher 32 bits that sincerely seems not a very good idea to use in most circumstances (out of memory very easy to cause) and so is not implemented in the NodeJs version especially because Js numbers are 53 bit wide (that's the biggest safe integer that can be stored in a double floating point value) and using bigint would be so slow that the performance improvements provided by the roaring data structure would not give any benefit |
If in your specific case you have just few bits more than 32 to store you can have more than one bitmap and split the number in higher bits, to select the right bitmap, and lower bits, to use in the selected bitmap. Is not going to be fun because bit operators in JavaScript works only on the lowest 32 bit, they are int32, so you will have to use floating point magic: division and truncation instead of shift left or &. And as said before, you cannot store all possible 64 bit integers in a JavaScript number, it can store maximum 53 bit integers. There is BigInt for bigger integers |
thanks @SalvatorePreviti |
Hi, I noticed that big numbers are being falsely deserialized. Is there a workaround?
code to reproduce:
The text was updated successfully, but these errors were encountered: