We will see how to count using any number system. Counting (number systems) We will see how to count and represent quantities using positional number systems, like our own decimal system. Skills: counting using any number system Concepts: positional number systems, base (radix) This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License. We will present number system concepts. We count objects – soldiers, words, carrots, stones, etc. Where does this topic fit? This presentation presents number system concepts. • Internet concepts – Applications – Technology – Implications • Internet skills – Application development – Content creation – User skills I’m not sure if it is true or not, but I’ve heard that Roman generals estimated the size of their armies by having each soldier put a stone on a pile. The bigger the pile, the bigger the army. The Romans wrote numbers like this: MMX Those Roman numerals were easy to read, but not suitable for doing arithmetic. For arithmetic, we needed positional numbers. Let’s use positional numbers to count stones. We have all learned to count using the decimal or base 10 number system. Using decimal numbers to count stones When you were small, you learned to count – you learned the concept of quantity. Later, you learned to write ten 10 symbols or glyphs to represent the quantities 0 through 9. 0 1 2 3 Here is the symbol or “glyph” for the quantity five in six different cultures. … 5 9 European Arabic-Indic Persian and Urdu Hindi We can count up to nine stones using our decimal or base 10 number system since it uses ten glyphs. Our glyphs, our “Arabic numerals” are relatively new. Here we some ancient glyphs for the quantity five. Mayan numbers date back to the fourth century. Tamil __ In our decimal system, what happens when you add the tenth stone? Mayan Let’s get back to our familiar decimal numbers. One more stone What happens when you have nine stones and add one more? How can we write that quantity? ? We move to the tens position.. Zero, carry 1 There is no glyph for the quantity ten, so we add a position. We “carry” one into the tens position, and reset the ones position to zero. 10 What happens if we put a 2 in the tens position? That gives us the number 20. To write the number for twenty stones, we need a 2 in the tens position. How about a two in the tens position and a 3 in the ones position? 20 That’s 23. Twenty three has a 2 in the tens position and a 3 in the ones position. You get the idea. 23 What comes after 99? What comes after 99? 99 The ones and tens position revert to zero and we carry one to the one hundreds position. The end result is 100? This is what happens when the odometer in your car goes from 99 miles to 100 miles. 100 The counting pattern continues indefinitely. The pattern continues with 228 stones. Here we have 228 stones. Eight in the ones position, and two in the hundreds and tens positions. 228 Interpreting the numbers in each position. 100 10 1 2 2 8 2 x 100 = 200 2 x 10 = 20 8 x 1 = 8 228 Do you see the pattern in the number positions? 1 10 100 1,000 … 10,000 Number positions 100,000 In the decimal (base 10) system, the positions go up by powers of 10. As shown here, we can think of 228 as 2 hundreds + 2 tens + 8 ones. 228 Each position is ten times the one to its right because we have ten glyphs in the decimal number system. What will be the next position? And the one after that? The Mayans used a base 20 number system with 20 glyphs – back when the Romans were stuck with Roman numerals. Mayan base 20 glyphs We use a decimal number system with 10 glyphs, but it turns out you can use any base or radix for a numbering system. The Mayans used a base 20 number system. Their 20 glyphs are shown here. The symbol for zero is a seashell. They date back to the fourth century. Computers and other IT devices use binary (base 2) numbers and programmers often use base 16 (hexadecimal numbers). Today’s IT systems use binary -- base 2 -numbers. And programmers often use hexadecimal -- base 16 – numbers. Binary: base 2 Hexadecimal: base 16 Binary numbers are written using only two glyphs. Here are the binary and hexadecimal glyphs. For hexadecimal numbers, we need 16 glyphs. 0 1 Here we are counting in binary, decimal and hexadecimal, but you can use any base for a number system. 0 1 2 3 4 5 6 7 8 9 A B C D E F Counting works the same regardless of the number system base (radix). When you run out of combinations, a carry is generated, and you keep going. Since there are more glyphs, hexadecimal numbers are generally shorter than decimal numbers, which are shorter than binary numbers. Think how fast the odometer on your car would overflow to the next position if there were only two, binary glyphs. The bigger the base, the shorter the numbers, but the harder it is to learn to do arithmetic. (We will see how arithmetic works in a subsequent presentation). Binary, decimal and hexadecimal are three common number systems, but we can count using any integer as a base. Binary number positions increase as powers of two. Do you see the pattern in the binary number positions? 1 2 4 8 32 … 16 Binary number positions Each position is two times the one to its right because we have two glyphs in the binary number system. What will be the next position? And the one after that? A binary number example 32 16 8 4 2 1 1 0 1 1 0 1 1 0 1 1 0 1 x 32 = 32 x 16 = 0 x 8 = 8 x 4 = 4 x 2 = 0 x 1 = 1 45 1 16 256 4,096 65,536 … 101101 is just a different way to write 45 – they both signify the same number of stones or whatever we are counting. Do you see the pattern in the hexadecimal number positions? Hexadecimal number positions 1,048,576 Hexadecimal number positions follow the same pattern, but they increase as powers of 16. Converting the binary number 101101 to decimal gives 45. A binary example Each position is 16 times the one to its right because we have 16 glyphs in the hexadecimal number system. What will be the next position? And the one after that? A hexadecimal number example We’ve seen how positional numbers of any base can be used to count. 256 16 1 A hexadecimal example 3 6 B 3 x 256 = 768 6 x 16 = 96 B x 1 = 11 875 Summary Base 20 Converting the hexadecimal number 36B to decimal gives 875. 36B is just a different way to write 875 – they both signify the same number of stones or whatever we are counting. This presentation focused on positional number systems. Base 10 We’ve seen how they worked, using binary, decimal and hexadecimal numbers as examples. Base 2 Base 16 All positional number systems are equivalent – you can express a given quantity using any number system. Programmers often communicate in hexadecimals, today’s IT systems use binary, and we are used to decimal. The Mayan number system was base 20. Self-study questions Self study questions 1. If I am counting in binary, what is 11111 plus 1? 2. If I am counting in binary, what is 11111 plus 11? 3. If I am counting in hexadecimal, what is FFFFF plus 1? 4. If I am counting in hexadecimal, what is aa3 plus 3? 5. If I am counting in hexadecimal, what is FFFFF plus F? 6. Write the number 12 (base 10) in binary, hexadecimal and trinary (base 3) 7. Write the number 1101011 (binary) in decimal, hexadecimal and trinary. 8. If I were a Mayan, how would I write the number 550 (base 10)? 9. True or false – all odd binary numbers end in 1? Links Links Mayan numbers: http://en.wikipedia.org/wiki/Maya_numerals Hindu-Arabic number system: http://en.wikipedia.org/wiki/Hindu-Arabic_numeral_system