1
$\begingroup$

This is more for my curiosity than anything else as I understand how to find the two's complement of a binary number via the standard approach which is to convert all 0s to 1s and 1s to 0s and then add $1_2$, but this "quick method" truly puzzles me. I see that the author of the book I am going through suggests that this method be skipped but I am wondering whether anyone understands what is going on here because I am truly lost.

enter image description here

enter image description here

This is all the description that is given. I don't understand why the first six bits are left alone while the last eight bits are changed. I would be much obliged if someone could provide some background to this methodology.

$\endgroup$

2 Answers 2

0
$\begingroup$

In that shortcut, let that right-most 1 bit left unchanged be $b$. Since $b$ is the right-most 1 bit all other bits on its right are 0s.

In the standard two's complement, when you first do the one's complement, $b$ will be the right-most zero and everything else that follows it on the right will be 1s. Then, if you add 1, that will result in a sequence of carry overs that will only stop when the carry bit is added to $b$ because $b$ is zero. This simply put $b$ and everything on its right back to their original value, but everything else on $b$'s left will be in their inverted value.

$\endgroup$
1
  • $\begingroup$ Aha, thank you for your reply. I believe I understand now. So this method is used whenever we have a series of zeroes corresponding to lesser significant bits always starting from the least significant bit position and ending when we encounter a 1 which would constitute a portion that we will not change. $\endgroup$ Feb 10, 2023 at 15:14
0
$\begingroup$

To add one to a binary number, you start from the right and zero out every one until you reach a zero. The you are done.

E.g. 0101110001111 + 1 = 0101110010000.

Notice that the last ones plus the first zero were changed and the next digits were unchanged.

Two's complement is bit flipping followed by incrementation. Hence the first zeroes plus the first one remain zero, and the next digits are changed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.