Difference between revisions of "CSC103: DT's Notes 1"
Line 640: | Line 640: | ||
Let's see how this actually works out. Remember the section above when we added two binary numbers together? Let's just concentrate on the bit that is the rightmost bit of both numbers (in computer science we refere to this bit as the ''least significant bit''). If we are adding two bits together, and if both of them can be either 0 or 1, then we have 4 possible possibilities: | Let's see how this actually works out. Remember the section above when we added two binary numbers together? Let's just concentrate on the bit that is the rightmost bit of both numbers (in computer science we refere to this bit as the ''least significant bit''). If we are adding two bits together, and if both of them can be either 0 or 1, then we have 4 possible possibilities: | ||
+ | <!-- | ||
0 0 1 1 | 0 0 1 1 | ||
+ 0 + 1 + 0 + 1 | + 0 + 1 + 0 + 1 | ||
---- ---- ---- ---- | ---- ---- ---- ---- | ||
− | + | --> | |
0 0 1 1 | 0 0 1 1 | ||
+ 0 + 1 + 0 + 1 | + 0 + 1 + 0 + 1 | ||
Line 651: | Line 652: | ||
Using the rules we created above for adding two bits together, we get the following results: | Using the rules we created above for adding two bits together, we get the following results: | ||
+ | <!-- | ||
0 0 1 1 | 0 0 1 1 | ||
+ 0 + 1 + 0 + 1 | + 0 + 1 + 0 + 1 | ||
---- ---- ---- ---- | ---- ---- ---- ---- | ||
0 1 1 1 0 | 0 1 1 1 0 | ||
+ | --> | ||
+ | 0 0 1 1 | ||
+ | + 0 + 1 + 0 + 1 | ||
+ | ---- ---- ---- ---- | ||
+ | 0 1 1 1 0 | ||
+ | |||
Let's take another step which, although it doesn't seem necessary, is absolutely essential. You notice that the last addition generates a carry, and the result is 10. We get two bits. Let's add a leading 0 to the other three resulting bits | Let's take another step which, although it doesn't seem necessary, is absolutely essential. You notice that the last addition generates a carry, and the result is 10. We get two bits. Let's add a leading 0 to the other three resulting bits | ||
− | + | <!-- | |
0 0 1 1 <--- a | 0 0 1 1 <--- a | ||
+ 0 + 1 + 0 + 1 <--- b | + 0 + 1 + 0 + 1 <--- b | ||
Line 664: | Line 672: | ||
| | | | ||
+---- C | +---- C | ||
+ | --> | ||
+ | |||
+ | 0 0 1 1 <--- a | ||
+ | + 0 + 1 + 0 + 1 <--- b | ||
+ | ---- ---- ---- ---- | ||
+ | 0 0 0 1 0 1 1 0 <--- S | ||
+ | | | ||
+ | +---- C | ||
+ | |||
Let's call the first bit ''a'', the second bit ''b'', the sum bit ''S'', and the extra bit that we just added ''C'' (for '''c'''arry). Let's show the same information we have in the four above additions into a table, similar to the truth tables we used before where we were discussing boolean algebra. | Let's call the first bit ''a'', the second bit ''b'', the sum bit ''S'', and the extra bit that we just added ''C'' (for '''c'''arry). Let's show the same information we have in the four above additions into a table, similar to the truth tables we used before where we were discussing boolean algebra. |
Revision as of 06:53, 10 September 2013
--© D. Thiebaut 08:10, 30 January 2012 (EST)