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?
Computer Science Stack Exchange is a question and answer site for students, researchers and practitioners of computer science. It only takes a minute to sign up.
Sign up to join this communityI'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?
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.