The 2's complement representation of the decimal value -15 is
Convert the magnitude, -15 to binary.
To make it 8 bits pad 4 extra bits to 1111 (Always Before)
Negate the number by inverting the bits and adding 1.In simple words
Take the 2's complement of the no
11110001 (from LSB when u see ist 1 leave it as it is and thereafter flip the all bits.)
To match the answer ignore most significant 3 bits ANS - 10001
actually 5 bits required to represent -15 in 2's compement
because range of 2's complement no is -2n-1 to +2n-1-1
For -15, we have to complement its binary value - 01111..
because range of 2's complement no is -2n-1 to +2n-1-1 .. therefore it will be 10001
In 2's complement representation positive integers are represented in its normal binary form while negative numbers are represented in its 2's complement form.