A: REVIEW - DECIMAL OR BASE 10 NUMBERS OCTAL, BINARY, AND HEXADECIMAL NUMBERS When we see a number like 2,578 we know the 2 counts for more than the 7, even though 7 is a larger number than 2. The reason the 2 counts for more than the 7 is because in our number system, the Hindu-Arabic numeral system, place value is more important than the size of the individual digit. When we talk about Decimal numbers, we are not just talking about numbers that have a decimal point, like 6.43. For now, any Base 10 number will be referred to as a Decimal number, and vice versa. In Base 10, there are 10 different digits that can occupy a place. They are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. If there are more than 9 items, we must represent that value using 2 or more digits. Back to the number 2,578. The 8 is in the ones column, and 1 can be written as 10 0. The 7 is in the tens column, and 10 can be written as 10 1. The 5 is in the hundreds column, and 100 can be written as 10 2. The 2 is in the thousands column, and 1000 can be written as 10 3. The value of each place can be written as a power of 10. B: OCTAL OR BASE 8 NUMBERS In Octal there are only 8 different digits that can occupy a single place. They are 0, 1, 2, 3, 4, 5, 6, and 7. In Base 10 there is no single digit to represent the number 10. In Base 8 there is no single digit to represent the number 8 or 9. If there are more than 7 items, we must represent that value using 2 or more digits. Given the number: 3, 462 8. The 2 is in the ones column, and 1 can be written as 8 0. The 6 is in the eights column, and 8 can be written as 8 1. The 4 is in the eight times eight, or 64s column, and 64 can be written as 8 2. The 3 is in the eight times eight times eight, or 512s column, and 512 is 8 3. Converting an Octal Number into a Decimal Number Suppose I have the number above: 3, 462 8 (Notice that there is a subscript after the number indicating that this is a Base 8 number. In most cases, if there is no subscript you can assume the given number is Base 10. Sometime a subscript of 10 is used to avoid confusion.) To convert the number 3, 462 8 we look at what each digit represents. The 3 is the number of 512s we have: 3 * 512 = 1,536 The 4 is the number of 64s we have: 4 * 64 = 256 The 6 is the number of 8s we have: 6 * 8 = 48 The 2 is the number of 1s we have: 2 * 1 = 2 Adding up the far right column, we get: 1,842 So, 3, 462 8 = 1, 842 10.
Converting a Decimal Number into an Octal Number Given the number 307, how can that Decimal Number be converted into an Octal number? The process is relatively straightforward. Look at the 4 digits from the previous Octal number, 3, 462 8. Going from left to right, the four columns represent the number of 512s, 64s, 8s, and 1s present. To begin the conversion of 307, we start by asking How many 512s are there in 307? Well, there aren t any, so we will write down the digit zero, just as a place-holder. -> 0xxx Next, we ask How many 64s are there in 307? There are 4. The 4 in the 64s column accounted for 256. Subtract 256 from 307, to get 51 remaining. Next, we ask How many 8s are there in 51? There are 6. The 6 in the 8s column accounted for 48. Subtract from 48 from 51, to get 3 remaining. -> 04xx -> 046x There are three 1s left, so our final answer is: -> 0463 So, 307 10 = 463 8. C: BINARY OR BASE 2 NUMBERS Binary Numbers may look odd at first because they consist of zeroes and ones, and nothing else. Some typical Binary Numbers are: 10111 or 1011011110110 or 10 or 10101010101 Given the number 10111 2. Let s identify the value of each of the ones. Going from right to left (or least significant to most significant): There is a 1 in the 1s column, and 1 can be written as 2 0. There is a 1 in the 2s column, and 2 can be written as 2 1. There is a 1 in the two times two, or 4s column, and 4 can be written as 2 2. There is a 0 in the two times two times two, or 8s column, and 8 can be written as 2 3. There is a 1 in the two times two times two times two, or 16s column, and 16 is 2 4. Converting a Binary Number into a Decimal Number Suppose I have the number from above: 10111 2 To convert the number 10111 2 we look at what each binary digit represents and add up the total. There is a 1 in the 16s column: 1 * 16 = 16 There is a 0 in the 8s column: 0 * 8 = 0 There is a 1 in the 4s column: 1 * 4 = 4 There is a 1 in the 2s column: 1 * 2 = 2 There is a 1 in the 1s column: 1 * 1 = 1 Adding up the far right column, we get: 23 So, 10111 2 = 23 10.
Converting a Decimal Number into a Binary Number The process of converting a Decimal Number into a Binary Number uses the same steps we saw previously when going from Decimal to Octal, with different numbers. Let s begin by identifying what each column represents in a Binary Number. Going from right to left, or smallest to largest, the columns are the 1s, 2s, 4s, 8s, 16s, 32s, 64s, 128s, 256s, 512s, and 1024s. To convert 487 into Binary, we start by asking How many 1024s are there in 487? (Note: 1024 is the 11 th column.) There aren t any, so write down a zero as a place-holder. Next, we ask How many 512s are there in 487? There are 0. How many 256s are there in 487? There is 1. -> 0xxxxxxxxxx -> 00xxxxxxxxx -> 001xxxxxxxx Subtract 256 from 487 to get 231 remaining. How many 128s are there in 231? There is 1. -> 0011xxxxxxx Subtract 128 from 231 to get 103 remaining. How many 64s are there in 103? There is 1. -> 00111xxxxxx Subtract 64 from 103 to get 39 remaining. How many 32s are there in 39? There is 1. -> 001111xxxxx Subtract 32 from 39 to get 7 remaining. How many 16s are there in 7? None. How many 8s are there in 7? None. How many 4s are there in 7? There is 1. -> 0011110xxxx -> 00111100xxx -> 001111001xx Subtract 4 from 7 to get 3 remaining. How many 2s are there in 3? There is 1. -> 0011110011x Subtract 2 from 3 to get 1 remaining. Finally, there is 1 one left. -> 00111100111 So, 487 10 = 111100111 2
D: HEXADECIMAL OR BASE 16 NUMBERS Saving the strangest for last, Hexadecimal Numbers look very weird at first. With a little bit of work you will see that they behave just like Octal and Binary Numbers. In Decimal there are 10 different digits that can occupy a place. They are 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. In Octal there are only 8 different digits that can occupy a place. They are 0, 1, 2, 3, 4, 5, 6, and 7. In Binary there are only 2 different digits that can occupy a place. They are 0 and 1. In Hexadecimal there are 16 different digits that can occupy a place. We start with the 10 digits most familiar to us - 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. But we need 6 more digits, so we will use letters, namely A, B, C, D, E, and F. Hold up one hand and count your fingers. In Base 10, you have 5. In Base 8, you also have 5. In Base 2, you have 101! And in our new Base 16, you still have 5. Now count the fingers on both of your hands. In Decimal you have 10 fingers. In Octal you have 12 fingers. In Binary you have 1010 fingers. In Base 16, you have A fingers. Basically, in Base 16 we must be able to represent 10, 11, 12, 13, 14, and 15 items using a single digit. So we let A 16 = 10, B 16 = 11, C 16 = 12, D 16 = 13, E 16 = 14, and F 16 = 15. A couple of interesting Hexadecimal numbers are DEAD 16 and BEEF 16 Given the number: 3AD 16. The D (or 13) is in the 1s column, and 1 can be written as 16 0. The A (or 10) is in the 16s column, and 16 can be written as 16 1. The 3 is in the sixteen times sixteen, or 256s column, and 256 is 16 2. Converting a Hexadecimal Number into a Decimal Number Suppose I have the number from above: 3AD 8 To convert the number 3AD 8 we look at what each digit represents. The 3 is the number of 256s we have: 3 * 256 = 768 The A is the number of 16s we have: 10 * 16 = 160 The D is the number of 1s we have: 13 * 1 = 13 Adding up the far right column, we get: 941 So, 3AD 168 = 941 10.
Converting a Decimal Number into a Hexadecimal Number Like before, we look at each column, see what value it represents, and then determine how many whole times the column value goes into the number we have left. Let s convert the Decimal Number 747 into a Hexadecimal number. The process is similar to what we did for Octal and Binary Numbers, except in each base the columns represent different values. In Base 16, the first four column values are: 16 0 = 1, 16 1 = 16, 16 2 = 256, and 16 3 = 4096. How many 4096s are there in 747? None. How many 256s are there in 747? There are 2. Subtract 2 times 256 from 747, to get 235 remaining. How many 16s are there in 235? There are 14. To represent 14 in one digit we use the number E. The E in the 16s column accounted for 224 = 14*16. Subtract from 224 from 235, to get 11 remaining. -> 0xxx -> 02xx -> 02Ex To represent 11 in one digit we use the number B. -> 02EB So, 747 10 = 2EB 16. Homework: 1. Convert the following Octal Numbers into Decimal Numbers: a. 27 8 b. 104 8 c. 572 8 d. 1,362 8 2. Convert the following Decimal Numbers into Octal Numbers: a. 29 b. 67 c. 130 d. 609 3. Convert the following Binary Numbers into Decimal Numbers: a. 101 2 b. 100011 2 c. 111001111 2 d. 101010101010101 2 4. Convert the following Decimal Numbers into Binary Numbers: a. 7 b. 33 c. 140 d. 299 5. Convert the following Hexadecimal Numbers into Decimal Numbers: a. 1B 16 b. B2 16 c. ABC 16 d. 101F 16 6. Convert the following Decimal Numbers into Hexadecimal Numbers: a. 17 b. 50 c. 239 d. 4108