<<< Data representation, cont. | Index | Sign extension >>> |
To represent a negative number:
start with the positive binary representation
invert every bit
add 1 to the result
Examples with 4-bit integers:
-1 == 0001 ==> 1110 ==> 1111 -4 == 0100 ==> 1011 ==> 1100 -7 == 0111 ==> 1000 ==> 1001
<<< Data representation, cont. | Index | Sign extension >>> |