Difference between revisions of "CSC103: DT's Notes 1"
Line 199: | Line 199: | ||
+ | ====Binary Arithmetic==== | ||
+ | |||
+ | So far, we can count in binary, and we now how to find the decimal value of a binary number. But could we perform arithmetic with binary numbers? If we can, then we're that much closer to figure out how to build a computer that can perform computation. Remember, that's our objective in this chapter: try to understand how something build with electronic circuits that operate with electricity that can be turned on or off can be used to perform the addition of numbers. If we can add numbers, surely we can also multiply, subtract, divide, and we have an electronic calculator. | ||
+ | |||
+ | Once again we start with decimal. Base 10. Only 10 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. | ||
+ | |||
+ | Let's add 133 to 385 | ||
+ | |||
+ | |||
+ | 1 3 3 | ||
+ | + 3 8 5 | ||
+ | ------------ | ||
+ | |||
+ | |||
+ | It's tempting to just go ahead and find the answer, isn't it? Instead let's do it a different way and concentrate only on 3 + 5 | ||
+ | |||
+ | 0 | ||
+ | 1 | ||
+ | 2 | ||
+ | 3 <---- we start at 3 | ||
+ | 4 +1 | ||
+ | 5 +2 | ||
+ | 6 +3 | ||
+ | 7 +4 | ||
+ | 8 +5 and we go down by 5 steps. | ||
+ | 9 | ||
+ | |||
+ | The result is 8. | ||
+ | |||
+ | 1 3 3 | ||
+ | + 3 8 5 | ||
+ | ------------ | ||
+ | <font color="magenta">8</font> | ||
+ | |||
+ | We move on the next column and add 3 + 8. | ||
+ | |||
+ | 0 | ||
+ | 1 | ||
+ | 2 | ||
+ | 3 <---- we start at 3 | ||
+ | 4 +1 | ||
+ | 5 +2 | ||
+ | 6 +3 | ||
+ | 7 +4 | ||
+ | 8 +5 | ||
+ | 9 +6 | ||
+ | ----- | ||
+ | 1 0 +7 | ||
+ | 1 1 +8 <--- the result is 8, but with a roll-over | ||
+ | |||
+ | |||
+ | Here we had to roll over our list of available digits. We know the rule! When we roll over we add 1 to the digit on the left. In this case the digit'''s''' on the left. We'll put this new digit above the third column of numbers as follows: | ||
+ | <font color="magenta">1</font> | ||
+ | 1 3 3 | ||
+ | + 3 8 5 | ||
+ | ------------ | ||
+ | <font color="magenta">1</font> 8 | ||
The answers to these questions, and the ensuing solutions are provided by two giants of computer science, '''George Boole''', and '''Claude Shannon''' who worked at very different times. | The answers to these questions, and the ensuing solutions are provided by two giants of computer science, '''George Boole''', and '''Claude Shannon''' who worked at very different times. |
Revision as of 10:51, 31 January 2012
--© D. Thiebaut 08:10, 30 January 2012 (EST)