

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


An important function of digital computers is the ability to use logical functions to perform arithmetic. The foundation of this is addition; if two binary numbers can be added, then they can just as easily be subtracted. Once we can add and subtract, we can then create an algorithm built on this foundation to multiply and divide. How, then, do we add two binary numbers? We will start simple and just consider adding together two binary bits. Since each bit has only two possible values, 0 or 1, there are only four ways these can be combined. These four possibilities, and the resulting sums in binary, are: 0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10 (= 2 in base 10) That fourth line though indicates that we need to deal with the possibility of having two output bits when we add our two input bits: the bit to the right which we call a âsum bitâ and a possible bit to the left which we call a âcarry bitâ. However this is analogous to what we do in base 10 when we add two decimal digits 0,1,2,âŚ,9. For example: 4 + 3 = 7 which does not require a second output âcarryâ digit 6 + 8 = 14 which does require a second output âcarryâ digit
We will certainly want to be able to add more than just two bits together. The digital computer would be of little use if it could only add 0 + 0 = 0, 0 + 1 = 1, 1 + 0 = 1, and 1 + 1 = 10. How can we create a circuit that would add two binary numbers of letâs say 23 bits each? This seems, at first, a little overwhelming so letâs just consider adding two binary numbers of 2 bits each. We want to add A 2 A 1 + B 2 B 1 , where A1,A 2 ,B1,B 2 ď{0,1}, for example 10+11, now how to do this? (And donât even think about answering â21â!) First we will make sure that we understand what the actual answers would be to make sure that our algorithm is correct, by listing the numbers 1 through 8 in base 10 in binary: 0 = 0 1 = 1 2 = 10 3 = 11 4 = 100 5 = 101 6 = 110 7 = 111 8 = 1000 MATH 248,Spring 2003
Note that the program Half_Adder on p. 171 uses LOGICAL variables and data, and this works exceptionally well given the framework of logical expressions and operators, but the program could be re-written using a few more IF-THENâs to use INTEGER variables and data in conjunction with logical expressions and operators. This would only be done if the user was just more comfortable with INTEGER vs. LOGICAL variables and data. Take a look at the logic circuitry at http://www.math.jmu.edu/~warnepg/wordbox/M248F01/PA2adder.doc
MATH 248,Spring 2003