let's just do it on a 4 bit example. You have 8 inputs and 4 outputs (technically you might need 5, but computers just ignore the last one if it happens. Integer overflow anyone?
You put in signals coresponding to the bits of 2 numbers you want to add, let's say 5 and 3. So 0101 and 0011. Power on the second and fourth line in one number and third and fourth in the second.
Then it goes through the gates to spit out 1000, or 8.
it's like adding, like I told you
(following numbers in binary of course)
0101
+ 0011
And you go from the left. 1+1 is 10, so carry 1, output 0 to the end
0+1 is 1, then 1+carry 1 = 10, carry 1 again, output 0
1+0 is 1, then 1+carry 1 = 10, carry 1, output 0
0+0 is 0, then 0+carry 1 = 1, output 1.
From what I know it goes through XOR and AND gates to get those results. XOR outputs 1 if the sum is 1, AND outputs 1 if the sum is 10.
so you combine those two, you get a half adder. Enough for the first bit, for the second you need two half adders because you have two inputs and potential carry (output of the first AND gate)
after you go through those, you again end up with 1 after XOR if the sum of the three is 1 or 11, and 1 after AND if the sum is 10 or 11. (so XOR is essentially the units and AND is the twos)
Chain a bunch of those together and you can add bigger numbers.
For subtraction you just use a special notation. They did some magic inventing it so that essentially if you write -3 + 5 you end up with 2 by going through the exact same circuit.
Back in the day multiplying was also just adding stuff over and over, now I think there's a separate circuit for that that's much more efficient. Don't ask me about how that works though, I don't have a clue.
