I'm being asked this question for my computer conceptes class, can't find anything about this in my text book, and have only been able to find half-baked answers googling it.
Why is binary subtraction referred to as the invert-add-shift-add method?
Asked By : Scott
Answered By : Yuval Filmus
I found an excellent answer here, which I summarize below.
Given two number $A,B$ in binary notation, we calculate $A-B$ by adding to $A$ the two's complement of $B$. Since the two's complement of $B$ is formed by inverting all bits of $B$ and adding $1$, one way to implement this idea is invert $B$, add the result to $A$, shift the carry $1$ bit (which will appear if $A\geq B$), and add it (i.e. $1$) to the result.
Best Answer from StackOverflow
Question Source : http://cs.stackexchange.com/questions/9457
0 comments:
Post a Comment
Let us know your responses and feedback