So I’m reading a 12 bit integer from a byte array. That number can be negative but I cant figure out how to convert that to a useable variable int16/int32 in c#. Have a feeling I’ll need to do something with bit shifting or other bitwise operations but I’ve been striking out so far. Can someone point me in the right direction.
var x = 0xFFF;
This needs to prints out as -1 but c# naturally casts to an int32 and prints out as 4095. If this needs cast to int16 or int32 how do I preserve the negative value.
32-bit: