Binary subtraction borrow out
On the right is the counting sequence for a 4-bit binary number, with decimal equivalents expressed in two ways. First we have the unsigned counting sequence, where all numbers are assumed to be positive. Then we see the signed sequence, which includes both positive and negative numbers. Because positive numbers are the same in both sequences, they can be used together without difficulty.
We only need to keep track of how we want to define the system. Indeed, the binary MSB is commonly known as the sign bit. The use of this bit to distinguish between positive and negative numbers also allows us to divide the counting sequence evenly between positive and negative numbers.
Now we need to look at the relationship between the binary numbers for positive and negative versions of the same magnitude. If we then increment the result, we get -1 , which is what we wanted.
Will this relationship hold for all negative numbers? In fact, it does work, as you can determine for yourself. To form the negative of any number, first complement all bits of the number. The result is the one's complement of the original number. Then, add 1 to the result, thus forming the two's complement of the original number. Arithmetic involving such signed numbers is known generally as two's complement arithmetic.
To check the validity of this process, let's take the two's complement of 0. We should logically get a result of 0. So, we start with , and form the one's complement Now add 1 to the result But this won't fit in a 4-bit number, so the extra 1-bit is lost, leaving a result of Remember to discard the carry from the highest-order bit.
Two's complement arithmetic always works this way. Therefore it is not possible to correctly take the two's complement of It will come back again as But if we invert B and add 1 with the low-order C in , we get the result of A - B. We can use Exclusive-OR gates, as shown to the right, to control whether we will add or subtract on any given occasion.
With a control input of 0, the XOR gates will leave the B input number unchanged, and will also apply a logic 0 as the initial input carry. This is exactly what we want in order to add the two numbers. However, if we apply a logic 1 to the control input, the XOR gates will invert the B input number to form its one's complement, and will also add 1 through the initial input carry.
This changes B to its two's complement. As the main concern in this module is with electronic methods of performing arithmetic however, it will not be necessary to carry out manual subtraction of binary numbers using this method very often.
This is because electronic methods of subtraction do not use borrow and pay back, as it leads to over complex circuits and slower operation. Computers therefore, use methods that do not involve borrow. These methods will be fully explained in Number Systems Modules 1. Just to make sure you understand basic binary subtractions try the examples below on paper.
Be sure to show your working, including borrows and paybacks where appropriate. Using the squared paper helps prevent errors by keeping your binary columns in line.
This way you will learn about the number systems, not just the numbers. This is not a problem with this example as the answer 2 10 10 still fits within 4 bits, but what would happen if the total was greater than 15 10?
As shown in Fig 1. When arithmetic is carried out by electronic circuits, storage locations called registers are used that can hold only a definite number of bits. If the register can only hold four bits, then this example would raise a problem. The final carry bit is lost because it cannot be accommodated in the 4-bit register, therefore the answer will be wrong.
To handle larger numbers more bits must be used, but no matter how many bits are used, sooner or later there must be a limit. Hons All rights reserved. Learn about electronics Digital Electronics.