I wonder how I implement the 2-complements method for binary-aritmetics when the number that is subtracted is less than the other number. For instance - If I want to subtract 13 from 12 ... i.e 12 -13 = -1.
I have tried the following steps:
1) 12 to binary using 8 bits (0000 1100
)
2) -13 to binary using 2-complements:
a) 13 into binary using 8 bits: 0000 1101
b) invert: 1111 0010
c) add 1: 1111 0010 + 1 = 1111 0011
So if I calculated correctly the result (1111 0011
) represents -13. So lets add this negative representation with 12:
00001100 + 11110011 = 11111111
So I do not understand the result - only only ones:s (1111...
)
This happens when the result is negative. Obviously I missed something.
Grateful for help!!!!