So, I was reading about 2's complement today and it got me wondering, how does that thing works? To be a little precise, we know that adding two binary numbers like A + B will actually give us A - B provided that B is in 2's complement form.
So what is the secret (maths actually) behind that thing? Anybody?
Arithmetic in two's complement is normal arithmetic of natural numbers that drops the first digit if it doesn't fit. 1111 is 15. 1111 + 1 = 10000, but, assuming 4 bits only 0000 fits into the result, thus 1111 + 1 = 0. For that reason 1111 could be called -1. Addition doesn't really care what you call things.