0
\$\begingroup\$

I'm trying to understand how binary addition works. If I understand it correctly, with two variables e.g. x and y you add a third one called c_i. On the other side, you add the sum and c_o.

The rules as far as I understood them: If you have two 1's, you carry 1 out and the result is 0.

Here is what confuses me:

1) In normal addition, you would carry in the 1 you carry out to the next line. Why don't we do this here, and therefore, what happens to the carry outs?

2) why is the carry in an "input" of its own, shouldn't it be just x and y since the carry ins/outs usually belong to one operation distinct from the values we use?

enter image description here

Thanks in advance!!

\$\endgroup\$
2
  • \$\begingroup\$ it operates exactly the same way as in grade school with pencil and paper add 9999 and 1001, most of the columns are three values being added together the carry out of one column is the carry in of the next. the only difference is that with binary it is simpler because there are only two numbers 0 and 1 not 10. If you were able to add 99999 and 10001 in grade school decimal with pencil and paper you can add binary numbers as well. Understand that in grade school there were a lot of implied zeros we didnt talk about in logic they need to be talked about. \$\endgroup\$
    – old_timer
    Aug 18, 2019 at 4:12
  • \$\begingroup\$ Try drawing the truth table for ordinary decimal 'schoolbook' addition, with the carry in and carry out shown explicitly, for a single digit. Then use this when you add some multi-digit decimal numbers with pencil and paper. The use pattern is exactly the same. \$\endgroup\$
    – Neil_UK
    Aug 18, 2019 at 5:52

4 Answers 4

2
\$\begingroup\$

what happens to the carry outs?

You can combine n full adder circuits to make an adder for n-bit numbers. When you do this, you connect the carry-out from each adder to the carry ins of the adder for the next most significant bit.

Here's an example adding 2 3-bit numbers, X = A + B:

schematic

simulate this circuit – Schematic created using CircuitLab

why is the carry in an "input" of its own, shouldn't it be just x and y since the carry ins/outs usually belong to one operation distinct from the values we use?

It's more efficient to just calculate the sum of 3 bits in one operation than to add x and y, and then add cin in a 2nd step.

\$\endgroup\$
4
  • \$\begingroup\$ Thank you, I don't think I really understand the first part though. They connect to the next most significant bit? Would you care to elaborate? Since if you look at A = 1, B = 0. Cin = 0. Shouldn't it add the carry out of the last line meaning the result should be 0 and carry in is 1 again. But in reality, the result is 1, and carry 0. \$\endgroup\$
    – user472288
    Aug 17, 2019 at 18:13
  • 1
    \$\begingroup\$ @user472288, suppose A is a 3 bit number made up of A0, A1, and A2. Then A1 is the next most significant bit in A after A0. \$\endgroup\$
    – The Photon
    Aug 17, 2019 at 18:32
  • 1
    \$\begingroup\$ @user472288, also, it sounds like you're thinking of adding multi-bit numbers in a serial operation (using one clock cycle to calculate each bit of the result), where the rest of us are talking about doing it as a parallel operation (calculating several bits of the result in a single operation). Either way is possible. For serial, you'd store the carry out when calculating the 0th bit and use it as the carry in for summing the 1st bit, and so on. \$\endgroup\$
    – The Photon
    Aug 17, 2019 at 18:36
  • \$\begingroup\$ Thank you photon! \$\endgroup\$
    – user472288
    Aug 17, 2019 at 18:38
1
\$\begingroup\$

You do!

That C_in is your "carry in" for that bit, and that "carry out" goes to the next bit's cin.

\$\endgroup\$
2
  • \$\begingroup\$ But, when you look at A = 1, B = 0 and Cin = 0, and you consider that the last line had a carry out of 1, should this not result in 1 + 1 meaning 0 again and carry out of 1? \$\endgroup\$
    – user472288
    Aug 17, 2019 at 18:16
  • \$\begingroup\$ @user472288: If you add two 1 bit numbers, the result can be a two bit nuumber, so 1 + 1 = 10. If you are doing multi-bit addition, then 001 + 001 = 010 . The carry from the least significant bit is added to the second bit - same as decimal addition, where 6 + 6 = 12. \$\endgroup\$ Aug 17, 2019 at 18:39
0
\$\begingroup\$
  1. Not sure I understand your confusion, You add the inputs (x,y) and carry in (c_in) and produce a sum. The upper bit of the sum now becomes the carry (c_out).
  2. C_in is infact an input of its own. Its named so because this addition described in the truth table is just a part of multi-bit summation. Here's an example:

$$ x_3x_2x_1\\ y_3y_2y_1\\ ----\\ s_3s_2s_1 $$

So, first step is to add \$x_1 + y_1\$ which produces \$s_1 and c_1\$ now in second step add \$x_2 + y_2 + c_1\$ which gives \$s_2 and c_2\$ So on..

\$\endgroup\$
0
0
\$\begingroup\$

binary math, no different from decimal math in grade school

  11111
+ 10001
=======

one plus one is 0b10, or zero carry the one.

     1
  11111
+ 10001
=======
      0

one plus one plus zero is zero carry the one.

    11
  11111
+ 10001
=======
     00

you can finish it from there the carry out of one column is the carry in of the next...just like paper and pencil math from grade school.

\$\endgroup\$

Your Answer

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

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