How to perform unsigned to signed conversion in Java?
Say I read these bytes: "6F D4 06 40" from an input device. The number is a longitude reading in MilliArcSeconds format. The top bit (0x80000000) is basically always zero and is ignored for this question. I can easily convert the bytes to an unsigned integer: 1876166208 But how do I convert that unsigned value into its final form of 31-bit signed-integer? So far all I've come up with is: if value & 0x40000000 then it's actually negative, need to convert it If it's negative, strip the top bit and do something with the remaining bits... So I can tell if it's a negative number, but in order to