somebody help

This is a discussion on somebody help within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Hello all. I'm having a horrible time studying binary numbers I already know the following 1+0=1 0+1=1 0+0=0 1+1=10 which ...

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    78

    somebody help

    Hello all. I'm having a horrible time studying binary numbers I already know the following

    1+0=1
    0+1=1
    0+0=0
    1+1=10
    which is all well and good but what happens when I get someting like this
    1+1+1+1+1+1=?
    The proffessor I believe thinks that we know this stuff already so he doesn't explain what to do in these situations
    for instance we were doing some binary muliplication and I ended up with something like this

    1011011
    1010111
    1011100
    1010000
    ^ this column right here is what I'm having problems with what do I add what do I carry over to the next column. ArggggggggggggH. I've been working on this for like one day now and I haven't got a clue

  2. #2
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    why dont you go and read your previous post instead of starting a new one asking the same question?

    here it is binary help read the replies.
    When no one helps you out. Call google();

  3. #3
    email for MystWind avatar MystWind's Avatar
    Join Date
    Feb 2005
    Location
    Holland , The Hague
    Posts
    88

    Red face

    ok i got me a book on it i'll tell you this :
    0 = 0000 0000
    1 = 0000 0001
    2 = 0000 0010
    3 = 0000 0011
    4 = 0000 0100
    5 = 0000 0101
    6 = 0000 0110
    so 7 will be 0000 0111
    etc etc etc .

    so what I have learned from this is that its a '1' is added at the back , untill its 'full' then an new '1' is added at the place where the last number in the latest row was . so 1+1+1+1+1+1= 6

    look 6 up in the collum i gave you and there you have your awnser
    Last edited by MystWind; 03-05-2005 at 11:26 AM. Reason: oops ! forgot 2 'nulls in every collum'
    PLay MystWind beta , within two years

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,663
    Add them in pairs
    t = a + b
    t = t + c
    t = t + d
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  5. #5
    Registered User
    Join Date
    Apr 2003
    Posts
    78

    alrighty but

    Okay but what do you when you are carrying to the next column I mean do you you carry all of the ones or keep the zero or what

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,663
    > 1+1=10
    1 + 1 is 0, carry 1
    Have you ever done long addition in base 10?

    Or did you just learn to press the + key on the calculator without any real understanding of how to add two numbers together

    Example.
    0011
    0011 +

    Working right-to-left, we do...

    Step 1 is 1 + 1 = 0, and carry(1)
    0011
    0011 +
    xxx0 carry 1

    Step 2 is 1 + 1 + carry(1) = 1 + carry(1)
    0011
    0011 +
    xx10 carry 1

    Step 3 is 0 + 0 + carry(1) = 1 + carry(0)
    0011
    0011 +
    x110 carry 0

    Step 4 is 0 + 0 + carry(0) = 0 + carry(0)
    0011
    0011 +
    0110 carry 0
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  7. #7
    Registered User
    Join Date
    Mar 2003
    Posts
    580
    when you get to the last bit of a byte and still have something to carry over, that 1 essentially just gets lost.
    See you in 13

  8. #8
    Registered User
    Join Date
    Apr 2003
    Posts
    78

    I knew that already

    I already knew all of that my friend I'm talking about a bunch of ones stacked on top of one another, for integer addition its easy you just carry over but for binary addition its totally different and I don't have a clue on how its done.
    here is an example of the question
    >1101
    >1001
    >1011
    >1111
    +0111
    as you can see there are like five ones on top of one another now for base 10 addition this is easy,but for binary addition I don't know how to go about using the carry bit for each operation

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,663
    But if you knew, you would see that the base has nothing to do with it - decimal (or integer as you incorrectly call it) works exactly the same way as binary addition.

    Add up all the values in a column, the column result is sum % 2, the carry is sum / 2, which you then propagate (as the carry) to one of the next columns.

    Which if you break the problem down into only trying to add two numbers together at once is easy.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  10. #10
    Registered User
    Join Date
    Mar 2004
    Posts
    494
    Salem is a good tutor, he is patient too.
    When no one helps you out. Call google();

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21