how do i calculate binary subtraction of 0000-0001 using 2's complement
my calculation looks like this
0001 >complement= 1110 > adding 0001 = 1111
finally adding it to
0000
1 1 1 1
-------
1 1 1 1 which is wrong
but in reverse i get correct answer
0000 >complement= 1111 > adding 0001 = 0000
0000
0001
-------
0001 which is correct
how do i calculate binary subtraction of 0000-0001 using 2's complement
my calculation looks like this
0001 >complement= 1110 > adding 0001 = 1111
finally adding it to
0000
1 1 1 1
-------
1 1 1 1 which is wrong
No it's not. You don't understand 2's complement arithmetic. 1's complement arithmetic has a plus zero (0000) and a negative zero (1111). 2's complement arithmetic has only a positive zero (0000). Therefore, 1111 represents -1 decimal in 2's complement arithmetic and your answer is correct.
but in reverse i get correct answer
0000 >complement= 1111 > adding 0001 = 0000
0000
0001
-------
0001 which is correct
4 bits in 2's complement would represent -8 to +7. 16 bits represents -32768 to 32767; there is only one zero in 2's complement notation.
The left most bit is the sign bit and you can "sign extend" that. so if you had 1111 (-1) sign extended to 16 bits 1111 1111 1111 1111 is still -1.
So is 0001 (1) sign extended to 16 bits 0000 0000 0000 0001 is still 1.