Here we first explain the relevant laws, the situation is to take less bits of the signed storage space to remove data and put in more symbolic storage space, such as: Char→short.
Rule: The original space symbol bit is repeatedly populated to the remaining bits in the new space.
eg. (negative case, positive number same)
char:1000 0000→
short:1111 1111 1000 0000
-------------------------------------------------------------------------------------------------
Prove:
A = (1000 0000) 2 = (-27) 10 = (-128) 10
B = (1111 1111 1000 0000) 2 = ( -215+214+213+......+28+27) 10
= (214 (1-2) + 213 +......+27) 10
= ( -214+213+......+27) 10
= ( -27) ten = ( -128) ten = A
The example is to be validated.
---------------------------------------------------------------------------------------------
Proof (General):
Set a = (1X) 2 = ( -2n-1) + (X) 2
B = (11......1 1X) 2 = ( -2m-1+2m-2+......+2n+2n-1) + + (X) 2
= ( -2n-1) + (X) 2 = A
Evidence.
>> sign extension for computer signed numbers