-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix bytesToNumber()
#42
Fix bytesToNumber()
#42
Conversation
This fixes `bytesToNumber()` to always return the result as an unsigned integer. Example: `byteArray` holds the value `2^32 - 3`, which is `11111111111111111111111111111101` in binary. The old implementation uses the `number` type, which is a signed integer, to calculate intermediate values. And because the most significant bit (MSB) is turned on, it interprets this as a negative number and returns `-3`.
Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @assafmo on file. In order for us to review and merge your code, please sign:
If you already signed one of this document, just wait to be added to the bot config. |
Thank you! Buffer is not available in browser but I think we use polyfill. Did you test it in browser? I'll checkout the branch and test. |
No, I've only tested it on nodejs. |
Thank you for your pull request. We require contributors to sign our Contributor License Agreement / Terms and Conditions, and we don't seem to have the users @assafmo on file. In order for us to review and merge your code, please sign:
If you already signed one of this document, just wait to be added to the bot config. |
@cla-bot check |
The cla-bot has been summoned, and re-checked this pull request! |
This fixes
bytesToNumber()
to always return the result as an unsigned integer.Example:
byteArray
holds the value2^32 - 3
, which is11111111111111111111111111111101
in binary. The old implementation uses thenumber
type, which is a signed integer, to calculate intermediate values. And because the most significant bit (MSB) is turned on, it interprets this as a negative number and returns-3
.