I'm trying to convert an int (max. 65535) to an two bytes array. In C I used an uint16, but Java doesn't know any unsigned values.
To convert the bytes to an array I tried to use this:
byte[] data = { (byte) ((num >> 8) & 0xff), (byte) (num & 0xff) };
But I only get: [63, -49] instead of: [63, 207], if I use 16335 as value. Is there a way to do this in Java?
I need this unsigned byte in an byte array to send it using an outputstream