I’m reading some bytes out of a byte stream and they look like this:
OUTPUT:
48 -84 -79 -84 -73 -79 46 48 -84
SHOULD BE:
48 44 49 44 55 49 46 48 44
I’d like to turn these into ascii characters but those negitive symbols are confusing me. This makes me think I don’t understand signed bytes. What on earth am I doing wrong here?
Looks like the highest bit is used as a parity bit, while your code assumes it is a sign bit.
-> 0011 0000 = 48
-> 1010 1100 = -84
Solution: mask away the highest bit by using
(value & 0x7f).