Click here for the calculator.
|
In addition to the usual base ten numbers the binary, octal, and hexadecimal systems are frequently used in Computer Science. Recall how base ten numbers are formed. The number 259 = 2*ten^2 + 5*ten + 9. The position of each digit indicates which power of ten is represented. The other systems work the same way except that the base is no longer ten. Octal numbers are written using eight distinct symbols -- the digits 0, 1, 2, 3, 4, 5, 6, and 7. Once we have counted up to 7 we run out of digits, so we must place a 1 in the "eights' column," just as we place a 1 in the 'tens column' after we have counted to 9 in base ten. Counting from one to twenty in base eight goes like this: 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 20, 21, 22, 23, 24. Notice that 24(base eight) = 20(base ten) since 24 = 2*eight + 4. As a further example, what is 70 (base ten) expressed in base eight? The answer is 106, since 70 = 1*eight^2 + 0*eight + 6. Someone once joked that arithmetic in base eight is just like arithmetic in base ten -- if you don't have any thumbs. Let's try a couple of examples: 1)In base eight, 24 + 13 = 37. This looks just like base ten. The only thing to remember is that 24 is two groups of eight plus 4 or 20(base ten), and 13 is one group of eight plus 3 or 11(base ten). Now, in base ten, 20 and 13 make 33. Well, 37(base eight) is three groups of eight plus 7, or 33(base ten). Did you get all that? 2)In base eight, 106 + 13 = 121. This does not look at all like base ten. We have a carry in the first column since 6 + 3 is 11 in base eight. That is because nine is 1 group of eight plus one more. (Remember: in base eight we run out of digits after 7 and so we move into the next column.) So we add our one in the eights' column to the carry getting a two. Then there is a 1 from 106 in the 64's column. That's right -- the 64's column. Well, 64 is eight squared you see. Binary numbers are written using only 0's and 1's. Counting from 1 to 9 in binary we have 1, 10, 11, 100, 101, 110, 111, 1000, 1001. Here we run out of digits very soon -- after counting to 1 infact. Notice that the powers of two -- 2, 4, 8, 16, etc. -- are represented by 10, 100, 1000, 10000, an so on -- just as the powers of ten are in base ten notation. Here are some examples: 1) 101 + 10 = 111. This is fairly simple since there is no carry. In base ten it translates to 5 + 2 = 7. 2) 1010 + 111 = 10001. This one involves a carry from one column to the next, since 1 + 1 = 10 in base two. We don't even have the luxury of a 2. This corresponds to 10 + 7 = 17 in base ten notation. Hexadecimal numbers are numbers base 16. This system is very popular in computer science -- especially in work close to the machine or hardware level. The hex digits consist of 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. Here A = ten, B = eleven, ... , F = sixteen. Learning to do arithmetic in this system is a bit tricky, but some people actually get fairly good at it. As an example we offer: 5A + F2 = 14C. A + 2 = C since counting from A we have A, B, C. Also, counting five places from F we have F, 10, 11, 12, 13 ,14. If you have understood all this ... very good! Now you are ready to practice your new skills using the calculator. |