balliztik1 Posted October 7, 2009 Author Share Posted October 7, 2009 Well, I recently dug around and found Admiral's post about binary numbers, so I decided to show this method I've been using for binary addition.Let's take two numbers in binary:110110101101Using the standard conversion, find what the numbers are in decimal, just to check our answer later.110110 = 2+4+16+32 = 54101101 = 1+4+8+32 = 45We know that in decimal, 54+45 is 99\. So that's the answer we'll be trying to achieve to test our method. To add in binary, simply do like you would in decimal. Line up the digits and combine. 110110+101101 ______ 211211In binary, there can be no 2s. What happens here? Let's examine a decimal addition problem to figure this out. 67+94 __ (15)(11)Your answer is not 1511, but rather 15 tens and 11 ones. The maximum digit you can have in decimal is 9, so you subtract 1 more, then add 1 to the next column. This is commonly referred to as "carrying the 1". So, for instance, the 11 ones becomes 1 one, then 1 is added to the tens, giving 16 tens, and 1 one. The same step is done with the tens to hundreds, giving 1 hundred, 6 tens, and 1 one, or 161\. 67+94=161.In binary, the same applies. We've got 211211\. Since binary only has 1 and 0, the 2s have to go. Instead of subtracting 10, though, we're subtracting 2, because one more than the highest digit possible (1) is 2\. So, we subtract 2 from the fours place, giving 0, and add 1 to the eights place, giving 2\. That 2 then gets subtracted and 1 is added to the sixteens, giving 2 sixteens. The same process repeats for sixteens, giving 3 thirty-twos. Subtract 2 from this and add 1 to the sixty-fours place. Your final number is 1 sixty-four, 1 thirty-two, 0 sixteens, 0 eights, 0 fours, 1 two, and 1 one. In binary, this means 1100011\. Check our answer by converting.1100011 = 1+2+32+64 = 9999 was the original answer in decimal, so this method works.Here's a little sequence of change: 110110+101101 ______ 211211 212011 220011 3000111100011 Link to comment Share on other sites More sharing options...
Eviltyphoon Posted October 7, 2009 Share Posted October 7, 2009 Now, do one for adding negative numbers in binary :D You'll need a sign bit for that and explain the transformation to whatever that negative number methods name is :P Link to comment Share on other sites More sharing options...
Drummerpete Posted October 7, 2009 Share Posted October 7, 2009 @.:Ev1ltyphoon:.:> Now, do one for adding negative numbers in binary :D You'll need a sign bit for that and explain the transformation to whatever that negative number methods name is :PWe did that the other week. I forgot.. Need to go over it.. Link to comment Share on other sites More sharing options...
Eviltyphoon Posted October 7, 2009 Share Posted October 7, 2009 @Pete:> We did that the other week. I forgot.. Need to go over it..hint: twos complement (or, that's how I learned it) Link to comment Share on other sites More sharing options...
Drummerpete Posted October 7, 2009 Share Posted October 7, 2009 @.:Ev1ltyphoon:.:> hint: twos complement (or, that's how I learned it)Yeah, that's what we did. I missed the first lesson and didn't catch up. Link to comment Share on other sites More sharing options...
Eviltyphoon Posted October 7, 2009 Share Posted October 7, 2009 @Pete:> Yeah, that's what we did. I missed the first lesson and didn't catch up.shame on you. (btw, first year in college/uni?) Link to comment Share on other sites More sharing options...
Drummerpete Posted October 7, 2009 Share Posted October 7, 2009 @.:Ev1ltyphoon:.:> shame on you. (btw, first year in college/uni?)Nah, Higher Computing (Scotland) Link to comment Share on other sites More sharing options...
Eviltyphoon Posted October 7, 2009 Share Posted October 7, 2009 @Pete:> Nah, Higher Computing (Scotland)awww. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now