Hi,Cameron
It is representing a number in binary base.(base 2).
Integer number in
java is represented by 32 bits.so when you representing a number say 2 ,it is as follows
0000 0000 0000 0000 0000 0000 0000 0010 = (0 x 1) +(1 x 2) +(0 x 4) ... and so on
when U represents a negative number takes the complement of the the (binary code )number (SAY 2) and add 1
(e.g)
complement of 2 in 32 bits =
1111 1111 1111 1111 1111 1111 1111 1101 +
0000 0000 0000 0000 0000 0000 0000 0001
====================================
1111 1111 1111 1111 1111 1111 1111 1110 = -2
=====================================
back to the Q
the MSB ie the most significant bit represents the sign of the number.
also the f = 15 in decimal base.binary reperesentation of15 =
(binary code) 1111 = (1 x 1) + (1 x 2) +(1 x 4)+(1 x 8)
when 0xf1 is converted to int (32 bits) the sign bit remains the same.
Actually it is -ve number.Ur thouught is correct.
Hope this clear Ur doubt.
Regards,
vkswami.