For 2's complement, substraction process by computer.
176-253=176+(-253)
176=10110000
253=11111101
253(inverse)=00000010
253(complement)=00000010+1=00000011
-253=253(complement)=00000011
176+(-253)=10110000+00000011=10110011=179?
but in fact 176-253=-77
is anybody tell me what's wrong here?
With 8 bits you can only represent numbers from -128 to 127 inclusive in 2's complement. Both your numbers lie outside that range. You would need at least nine bits to do the calculation you want to do.
In 2's complement the most significant bit (MSB, the first bit from the left), indicates the sign, 1 for negative numbers and 0 for non-negative numbers. The value:
is not -253, but is 3.
Doing your calculation in 9 bits yields:
Note that all the negative numbers have MSB=1 and all the non-negative numbers have MSB=0.