I am trying to execute bitwise or byte value that I have in Java.
For example, I run:
byte b = (byte)0b11111111; int result = 0 | b;
My expected result for this would be 0b00000000 00000000 00000000 11111111 or 255 . However, I get -1 or 0b11111111 11111111 11111111 11111111 .
I assume that Java will convert my byte to an int extension through a character extension before performing the operation, and I was just curious if there was a way to get the desired result without using a bit mask ( 0b11111111 ).
source share