document.write( "Question 1172437: evaluate the following in base (2) arithmetic
\n" ); document.write( "(a) 1010+11011+111011
\n" ); document.write( "(b) 1100110-100111
\n" ); document.write( "

Algebra.Com's Answer #797461 by greenestamps(13215)\"\" \"About 
You can put this solution on YOUR website!


\n" ); document.write( "There are many different ways to perform operations like these in base 2. I will demonstrate a couple of different options for each problem.

\n" ); document.write( "a) 1010+11011+111011

\n" ); document.write( "(1) One option is to add two of the numbers in base 2 and then add the third number to that sum. This is a good option for adding three numbers in base 2, because adding two numbers in base 2 is a fairly simple process. You wouldn't want to use this method if you were adding 10 or 100 numbers in base 2.

\n" ); document.write( "The addition table for base 2:

\n" ); document.write( " 0 1
\n" ); document.write( " +-------
\n" ); document.write( " 0 | 0 1
\n" ); document.write( " 1 | 1 10\r
\n" ); document.write( "\n" ); document.write( "Adding the first two numbers in base 2:\r
\n" ); document.write( "\n" ); document.write( " 1 1 <-- the \"carry\"s
\n" ); document.write( " 1 0 1 0
\n" ); document.write( " 1 1 0 1 1
\n" ); document.write( " ----------
\n" ); document.write( " 1 0 0 1 0 1\r
\n" ); document.write( "\n" ); document.write( "In detail....
\n" ); document.write( "last (rightmost) column: 0+1 = 1
\n" ); document.write( "2nd column: 1+1 = 10; write the 0 and carry the 1
\n" ); document.write( "3rd column: 1+0+0 = 1
\n" ); document.write( "4th column: 1+1 = 10; write the 0 and carry the 1
\n" ); document.write( "5th column: 1+1 = 10; write the 0 and carry the 1
\n" ); document.write( "done\r
\n" ); document.write( "\n" ); document.write( "Then adding the third number to that sum:\r
\n" ); document.write( "\n" ); document.write( " 1 1 1 1 1 1 <-- the \"carry\"s
\n" ); document.write( " 1 0 0 1 0 1 <-- sum of first two base 2 numbers
\n" ); document.write( " 1 1 1 0 1 1 <-- third number
\n" ); document.write( " ------------
\n" ); document.write( " 1 1 0 0 0 0 0\r
\n" ); document.write( "\n" ); document.write( "In detail....
\n" ); document.write( "last (rightmost) column: 1+1 = 10; write the 0 and carry the 1
\n" ); document.write( "2nd column: 1+1 = 10; write the 0 and carry the 1
\n" ); document.write( "3rd column: 1+1 = 10; write the 0 and carry the 1
\n" ); document.write( "4th column: 1+1 = 10; write the 0 and carry the 1
\n" ); document.write( "5th column: 1+1 = 10; write the 0 and carry the 1
\n" ); document.write( "6th column: 1+1+1 = 11; write the 1 and carry the 1
\n" ); document.write( "done\r
\n" ); document.write( "\n" ); document.write( "ANSWER: 1010+11011+111011 = 1100000 (base 2)
\n" ); document.write( "(2) Another option is to add all the numbers at the same time using base 10 arithmetic, obtaining column sums in base 10, then convert those base 10 digits to base 2.\r
\n" ); document.write( "\n" ); document.write( " 1 0 1 0
\n" ); document.write( " 1 1 0 1 1
\n" ); document.write( " 1 1 1 0 1 1
\n" ); document.write( " ------------
\n" ); document.write( " 1 2 3 0 3 2\r
\n" ); document.write( "\n" ); document.write( "Now, starting from the rightmost column again, convert the base 10 digits to base 2.\r
\n" ); document.write( "\n" ); document.write( "2 (base 10) = 10 (base 2): 1 2 3 0 3 2 --> 1 2 3 0 3 0
\n" ); document.write( " + 1 0
\n" ); document.write( " -----------
\n" ); document.write( " 1 2 3 0 4 0
\n" ); document.write( "4 (base 10) = 100 (base 2): 1 2 3 0 4 0 -->
\n" ); document.write( " 1 2 3 0 0 0
\n" ); document.write( " + 1 0 0 0
\n" ); document.write( " -----------
\n" ); document.write( " 1 2 4 0 0 0
\n" ); document.write( "4 (base 10) = 100 (base 2): 1 2 4 0 0 0 -->
\n" ); document.write( " 1 2 0 0 0 0
\n" ); document.write( " + 1 0 0 0 0 0
\n" ); document.write( " ------------
\n" ); document.write( " 2 2 0 0 0 0
\n" ); document.write( "2 (base 10) = 10 (base 2): 2 2 0 0 0 0 -->
\n" ); document.write( " 2 0 0 0 0 0
\n" ); document.write( " + 1 0 0 0 0 0
\n" ); document.write( " -----------
\n" ); document.write( " 3 0 0 0 0 0
\n" ); document.write( "3 (base 10) = 11 (base 2): 3 0 0 0 0 0 --> 1 1 0 0 0 0 0\r
\n" ); document.write( "\n" ); document.write( "And again the answer is 1010+11011+111011 = 1100000 (base 2)

\n" ); document.write( "(b) 1100110-100111
\n" ); document.write( "(1) One option is to use the same process as in base 10, but doing all the arithmetic in base 2.\r
\n" ); document.write( "\n" ); document.write( "Let's look first at a subtraction problem in base 10, where \"borrowing\" is required. We will modify the process a bit from what is usually taught in schools.\r
\n" ); document.write( "\n" ); document.write( " 4 3 6
\n" ); document.write( " - 2 5 7
\n" ); document.write( " --------\r
\n" ); document.write( "\n" ); document.write( "Borrowing is required. We take 1 from the 3, making it a 2 and changing the 6 to 16. Then we have to borrow in the next column also, so we take 1 from the 4, making that a 3 and making the 2 a 12. Then we have a subtraction where no borrowing is required:\r
\n" ); document.write( "\n" ); document.write( " 3 12 16
\n" ); document.write( " - 2 5 7
\n" ); document.write( " --------
\n" ); document.write( " 1 7 9\r
\n" ); document.write( "\n" ); document.write( "Now let's do the same thing for our base 2 subtraction problem.\r
\n" ); document.write( "\n" ); document.write( " 1 1 0 0 1 1 0
\n" ); document.write( " - 1 0 0 1 1 1
\n" ); document.write( " --------------\r
\n" ); document.write( "\n" ); document.write( "last (rightmost) column: we need to borrow; make the 1 in the column to the left 0 and change the 0 to a 2:\r
\n" ); document.write( "\n" ); document.write( " 1 1 0 0 1 0 2
\n" ); document.write( " - 1 0 0 1 1 1
\n" ); document.write( " --------------\r
\n" ); document.write( "\n" ); document.write( "next column: we need to borrow again; make the 1 in the column to the left 0 and change the 0 to a 2:\r
\n" ); document.write( "\n" ); document.write( " 1 1 0 0 0 2 2
\n" ); document.write( " - 1 0 0 1 1 1
\n" ); document.write( " --------------\r
\n" ); document.write( "\n" ); document.write( "third column: we need to borrow again; now we need to go several places to the left to find where we can do the borrowing. Change the \"1 0 0 0\" to \"0 1 1 2\":\r
\n" ); document.write( "\n" ); document.write( " 1 0 1 1 2 2 2
\n" ); document.write( " - 1 0 0 1 1 1
\n" ); document.write( " --------------\r
\n" ); document.write( "\n" ); document.write( "And now at the left we need to borrow one last time; change the leading \"1 0\" to \"0 2\":\r
\n" ); document.write( "\n" ); document.write( " 0 2 1 1 2 2 2
\n" ); document.write( " - 1 0 0 1 1 1
\n" ); document.write( " --------------\r
\n" ); document.write( "\n" ); document.write( "And now we can do the subtraction without borrowing:\r
\n" ); document.write( "\n" ); document.write( " 0 2 1 1 2 2 2
\n" ); document.write( " - 1 0 0 1 1 1
\n" ); document.write( " --------------
\n" ); document.write( " 1 1 1 1 1 1\r
\n" ); document.write( "\n" ); document.write( "ANSWER: 1100110-100111 = 111111 (base 2)\r
\n" ); document.write( "\n" ); document.write( "(2) In base 2, as in base 10, it is sometimes easier to do a subtraction by changing one of the numbers first and then correcting the result accordingly.\r
\n" ); document.write( "\n" ); document.write( "For example, in base 10, you might do the subtraction 1000-736 by first doing 999-736 = 263 and then adding 1 to the result. Or you might so the subtraction 39527-19528 by first doing 39528-19528 = 20000 and then subtracting 1 from the result.\r
\n" ); document.write( "\n" ); document.write( "In this base 2 subtraction problem, the final digits of the two numbers differ by 1, so this strategy can be useful.\r
\n" ); document.write( "\n" ); document.write( "So instead of doing 1100110-100111, we can do 1100111-100111 and then subtract 1 from our result.\r
\n" ); document.write( "\n" ); document.write( " 1 1 0 0 1 1 1
\n" ); document.write( " - 1 0 0 1 1 1
\n" ); document.write( " --------------
\n" ); document.write( " 1 0 0 0 0 0 0\r
\n" ); document.write( "\n" ); document.write( "Then subtracting 1 from this result we get the previous result:\r
\n" ); document.write( "\n" ); document.write( " 1 0 0 0 0 0 0
\n" ); document.write( " - 1
\n" ); document.write( " --------------
\n" ); document.write( " 1 1 1 1 1 1\r
\n" ); document.write( "\n" ); document.write( "And here too we see this result agrees with the one we got previously.\r
\n" ); document.write( "\n" ); document.write( "Note that last subtraction in base 2, where details of the subtraction process are not shown, is similar to 1000000-1 = 999999 in base 10. \n" ); document.write( "
\n" );