bitwise « byte « Java Data Type Q&A





1. Bitwise AND, Bitwise Inclusive OR question, in Java    stackoverflow.com

I've a few lines of code within a project, that I can't see the value of...

buffer[i] = (currentByte & 0x7F) | (currentByte & 0x80);
It reads the filebuffer from a file, stored ...

2. Bitwise operators in Java acting on two bytes    stackoverflow.com

This should be simple but I'm having trouble changing some C code that uses bitwise operators and shifts into Java. In C I have:

unsigned short Color(byte r, byte g, byte b)
{
  ...

3. how to mask byte value in java    stackoverflow.com

My problem is some like this. I have some calculation in byte in Java. In some calculation I get my desired result "2a" in byte value but in some calculation I get ...

4. Byte shift inverse operation    stackoverflow.com

I have this code

byte[] b = new byte[]{-33,-4,20,30};
System.err.println(Arrays.toString(b));

int x =  (b[0] << 24) + (b[1] << 16) + (b[2] << 8) + b[3];

b = new byte[]{(byte)(x >> 24), (byte)(x >> ...

5. Bitwise OR of signed byte value    coderanch.com

Since bitwise OR is a well-defined operation, one has to read something into the pharse "desired result". If an operation does what it's defined to do, how can that not be the "desired result"? What often catches people off guard are two things: 1. byte is signed, so it holds values in the range [-128, +127], as opposed to being unsigned ...

6. Byte-How to use bitwise operators?    coderanch.com

A typical use of the byte primitive is to read from and write to streams. See InputStream and OutputStream in the Java API docs. As far as the use of bitwise operators go, there are lmiitless situations in which these might be useful. If you look at the fifth post from the bottom in this thread from the "Programming Diversions" forum, ...

7. Bitwise Xor of bytes    coderanch.com