
General Electronics Chat Discussion forum for general chat about anything electronics related, including asking questions about material in the All About Circuits Ebook, Worksheets, and Videos. 

Thread Tools  Display Modes 
#1




Binary subtraction
I've been looking at digital arithmetic, and have easily understood addition using half adders, full adders and arrays of full adders, but when it comes to subtraction I don't really get it.
My book shows a circuit for a half subtractor, that is exactly the same as that for a half adder, except the "minued" input (The input 'A', in 'AB') to the AND gate (Borrow output) is inverted. The main thing I don't understand is the idea of 'borrowing' a bit. I mean when you 'carry' a bit in addition, you will only ever directly affect the next higher significant bit, but the way I learnt to do subtraction when I was little means that if the next higher significant digit is a zero, then you have to affect the next higher significant digit to that, and so on, until you come to a nonzero digit. When I've done some binary subtractions on paper the same thing applies. But how can a full subtractor, which is connected only to its next higher significant bit (and lower significant), take account of this standard subtraction algorithm*, when the next higher significant bit is a zero? It means having to change even higher significant bits, that it's not directly connected to. So how can it do it? Basically I'm having trouble connecting the hand calculations of binary subtraction, to the way the circuits work. I'm aware there are a few different subtraction algorithms that are used, using modular arithmetic and stuff, so I'm not really sure which is the best to learn. For instance I'm not sure that all of them will allow negative differences, which is probably needed for most applications. *This is an example of what I mean by this subtraction algorithm (in binary): Until this point there is no problem, but then we have for the 4th bit, 01, so we must look at the 5th bit. We can 'borrow' this bit, and have the sum 10  1 (in decimal 21) which equals 1, and lowers the '10' to '01', meaning the '1' in '10' becomes 0....like so: We then have to repeat this cause we have again, 01, so we end up with: (where I have changed the upper value to acoount for borrows). So we have 1101011110010 = 111001 which in decimal is 107  50 = 57 I'm ok with this so far, since we have only had to affect the bit immideately higher to the one we're computing, and in the circuit of a full subtractor, this is accounted for by the borrowin connection. But what if we change the sum slightly to: At this point, we must borrow again from the next bit since we have 01, but the next bit is '0', so we must go to the next nonzero bit, '1'. We then have the sum, 1001 (41 in decimal) which equals 011 (3 in decimal). So we have: This is the whole point I'm trying to make: In this sum we have not only had to increment the next highest significant bit, (bit 5, which changed from 0 to 1), but also had to go even higher to the next bit and change that (Bit 6 changed from 1 to 0)....but in an array of fullsubtractors, each subtractor is only connected to consecutive bits, so how can it be possible to perform a sum like this, where nonconsecutive bits are being directly affected as well? Thanks 
#2




Each circuit (here a subtractor) is designed to perform a specific function. Now, a 4bit subtractor for example can not subtract a number with more than 4 bits. Thus the subtractor will borrow bits until it does not need to borrow more or it has reached the last bit and it can not borrow more.
Think like that: The second bits stage says: "Did the first bits stage borrowed from me?" If yes it performs the appropriate function, if not it performs another function. Then it says: "Do i need to borrow from the third bits stage?" If yes it requests a borrow bit from the fourth bits stage, if not it does not request anything. By taking into account these two questions the same time it designs whether to request a borrow bit from the next stage or not. Each stage works in the same manner. Think of it!
__________________
>> Troubleshooting is an art << http://www.youtube.com/watch?v=hC7KYbFBPHA http://www.youtube.com/watch?v=StNJlRTWs9k http://www.youtube.com/watch?v=j4h3l9O4fc http://www.youtube.com/watch?v=E0jZJ...eature=related 
#3




Hi Mik3, thanks for the comment, I understand that to perform an addition or subtraction on an nbit number, you need an nbit adder/subtractor, but my confusion is with the individual actions and connections of full subtractors with regards to the subtraction algorithm shown above.
I have drawn a 4bit subtractor in paint to try and emphasise my point: Where the sum is AB, D represents the differences for each bit, and B in/B out are Borrowin/Borrowout respectively. This seems to contradict the sum I did above using the subtraction algorithm I'm familiar with. 
#4




I figured out that the subtractor circuits I have been looking at work on a different algorithm to the one I have shown above, whcih also explains the inverted input to the AND gate. Case closed!

#5




In the circuit above, each FS stage will borrow form the next FS stage and so on. Dont think of it that the FS0 has to borrow from all the following stages.
__________________
>> Troubleshooting is an art << http://www.youtube.com/watch?v=hC7KYbFBPHA http://www.youtube.com/watch?v=StNJlRTWs9k http://www.youtube.com/watch?v=j4h3l9O4fc http://www.youtube.com/watch?v=E0jZJ...eature=related 
#6




I've realised that I've been looking at two different methods of subtraction....one is the method of complements, and the other is the method of borrowing each of which has it's own circuit.
The method of complementing works by addition of positive numbers, and simply uses full adders and inverters, and I understand this method completely. The circuit looks like this: When the control line is 1, each bit of B will be inverted, else it will remain the same, so this switches between addition/subtraction. What I still don't get at all is the method of borrowing. Quote:
Here is the circuit I've been looking at for borrowing: Note: this is NOT the same circuit as above, since it is the borrow part of A that is inverted, rather than the whole of B (which is its 'one's complement'). Each of these fullsubtractors is joined together as I have shown in my first diagram. Perhaps sources using this diagram for borrowing simply fail to mention this problem of borrowing from 0, since complementing is a more effective method anyway? Otherwise, it's obviously me that doesn't get it. In that case could you please walk me through the subtraction: using the above circuit? Thanks alot 
Tags 
binary, subtraction 
Related Site Pages  
Section  Title  
Worksheet  Digital codes  
Worksheet  Binary math  
Textbook  Lookup tables : Principles Of Digital Computing  
Video Lecture  Binary Conversion  Converting Binary to Decimal  Digital  
Textbook  A FullAdder : Combinational Logic Functions  
Textbook  7segment display : Digital Integrated Circuits  
Textbook  Subtraction : Binary Arithmetic  
Textbook  Negative binary numbers : Binary Arithmetic  
Textbook  Decimal versus binary numeration : Numeration Systems  
Textbook  Octal and hexadecimal numeration : Numeration Systems 
Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
binary to ami line code using a nexys spartan 3  alan1981  Homework Help  3  03012008 08:49 PM 
BCD subtraction woes  mentaaal  Homework Help  8  02242008 11:37 PM 
Binary clock  arthur92710  General Electronics Chat  86  02232008 04:33 PM 
Whats that old binary code thing? 1,0.1?  arthur92710  General Electronics Chat  7  10242007 08:33 PM 
8bit binary adder using two 7483s and 7seg displays  JoeyB  Homework Help  3  03222007 03:37 PM 
Thread Tools  
Display Modes  

