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

Bitwise OR of signed byte value computed #24

Open
axkr opened this issue Apr 3, 2019 · 0 comments
Open

Bitwise OR of signed byte value computed #24

axkr opened this issue Apr 3, 2019 · 0 comments

Comments

@axkr
Copy link

axkr commented Apr 3, 2019

SpotBug complaints: Byte values are sign extended to 32 bits before any bitwise operations are performed on the value. Thus, if b[0] contains the value 0xff, and x is initially 0, then the code ((x << 8) | b[0]) will sign extend 0xff to get 0xffffffff, and thus give the value 0xffffffff as the result.

Should this be?

value |= (b & 0xff);
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

1 participant