Java byte array contains negative numbers

In Java, byte is a signed value (using two’s complement to encode negative values), so what you see it correct if unexpected by most people.

To convert a byte to an unsigned int value, use b & 0xff

Leave a Comment