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 'A-B') 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 non-zero 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, 0-1, so we must look at the 5th bit. We can 'borrow' this bit, and have the sum 10 - 1 (in decimal 2-1) 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, 0-1, so we end up with:
(where I have changed the upper value to acoount for borrows).
So we have 1101011-110010 = 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 borrow-in connection.
But what if we change the sum slightly to:
At this point, we must borrow again from the next bit since we have 0-1, but the next bit is '0', so we must go to the next non-zero bit, '1'. We then have the sum, 100-1 (4-1 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 full-subtractors, each subtractor is only connected to consecutive bits, so how can it be possible to perform a sum like this, where non-consecutive bits are being directly affected as well?
Thanks
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 'A-B') 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 non-zero 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):
Rich (BB code):
01101011
-0110010
1001
Rich (BB code):
01001011
-0110010
11001
Rich (BB code):
00001011
-0110010
111001
So we have 1101011-110010 = 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 borrow-in connection.
But what if we change the sum slightly to:
Rich (BB code):
01001011
-0110010
1001
Rich (BB code):
00101011
-0110010
11001
Thanks