Numbers in Other Bases We’ll need to learn the basics about different number bases in order to understand the cryptography in the next section. When we first learned about place values in grade school, we wrote 364 = 3 · 100 + 6 · 10 + 4. After learning about exponents, we could rewrite this as 364 = 3 · 102 + 6 · 101 + 4 · 100. In our number system, we write integers in a place-value notation, where each place indicates a different power of 10. The Babylonians (of more than 3000 years ago) were the first people to use place-value notation. The Babylonians shared their invention with the Hindus (before 600 B.C.), and the Hindus transmitted it to the Arabs (by 600 A.D.), and the Arabs shared it with Europe around 1200 A.D. The choice of 10 as the “base” is no accident; look at your fingers! But other bases have been used. The Babylonians sometimes used the base 60, and the ancient Mayans used the base 20. Today, numbers written in the bases 2, 8 and 16 are used by computers. Let’s look at base 8. In base 8, the digits that are used are 0, 1, 2, 3, 4, 5, 6, 7. The largest digit in any base is always one less than the base. Think about base 10. We use the digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and 9 is one less than 10. When you see a number written 4238, the subscript tells you the base. If there is no subscript, then the default base is base 10. The way we say the number 4238 is “four two three base eight”. The 3 is in the 80 place, the 2 is in the 81 place and the 4 is in the 82 place. So to see what this number is equivalent to in base 10, we’ll write 4238 = 4 · 82 + 2 · 81 + 3 · 80 = 256 + 16 + 3 = 275 Now suppose we want to do the opposite procedure; that is, convert a number from base 10 to base 8. We do this by repeated division by 8. Let’s convert the number 7492 to base 8. One division by 8 gives 7492 ÷ 8 = 936 R 4 Here, the R stands for remainder. This means that 7492 has 936 8’s and 4 ones. So 4 goes in the 80 spot. OK, let’s divide again. 936 ÷ 8 = 117 R 0 This means that 7492 has 117 82’s and no 81’s. So 0 goes in the 81 spot. We keep repeating this division: 117 ÷ 8 = 14 R 5 14 ÷ 8 = 1 R 6 1 ÷ 8 = 0 R 1. Copyright 2007. Number Theory and Cryptology for Middle Level Teachers. Developed by the Math in the Middle Institute Partnership, University of Nebraska, Lincoln. 1 How do we know when to stop? We stop when our quotient is 0. Then write down the remainders with the first remainder in the 80 spot, the second remainder in the 81 spot, etc. We find that 7492 = 165048. In general, to convert from base 10 to another base, repeatedly divide by the desired base until the quotient is 0. Then list the remainders to get the number in the new base. Here’s a fun little exercise. Convert the largest 3 digit number in base 8 to base 10. Well, that number would be 7778. When we convert, we get that 7778 = 7 · 82 + 7 · 81 + 7 · 80 = 511. The number 511 is one less than 83 = 512. Surprising? Not really. Think about the biggest three digit number in base 10. It’s 999, which is one less than 103 = 1000. Base 16, which is called the hexadecimal number system, is interesting because we run out of digits to use in representing numbers. We need digits for 0, 1, 2, . . . , 8, 9, 10, 11, 12, 13, 14, 15, but since, for example, 12 already has two digits in it, we use letters for the two-digit numbers. That means our “digits” are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A,B,C,D,E, F, where A represents 10, B is 11, C is 12, D is 13, E is 14 and F is 15. Let’s convert the number C516 to base 10. C516 = 12 · 161 + 5 · 160 = 197. If you’ve built a web page using HTML, you may have used the hexadecimal system to set your background color on the web page. Background colors are coded in 6 digit numbers, where the first two numbers (or letters) are the hexadecimal number for the amount of red in the color, the next two indicate how much green is in the color and finally the last two indicate how much blue is in the color. A color code such as FF119A will set the background color to have as much red as is allowed, not much green and a moderate amount of blue. ________________________________________________________________________ Exercise Convert the following numbers to base 10: • 3048 • FFD16 • 10112 (This number is represented in the binary system, a computer’s favorite!) • 41336 Exercise Convert the following base 10 numbers to the indicated base: • 851 to base 8 • 1389 to hexadecimal • 322 to binary • 677 to base 9 ________________________________________________________________ You can do all sorts of other fun stuff with numbers in other bases. You can learn how to add, subtract, multiply and even divide! To learn how to do these arithmetic operations, it always helps to think about how it works in base 10. If you’re interested in getting started on this, here are some addition and subtraction problems. ________________________________________________________________________ Copyright 2007. Number Theory and Cryptology for Middle Level Teachers. Developed by the Math in the Middle Institute Partnership, University of Nebraska, Lincoln. 2 Exercise Add: • 2237 + 5617 • AB7816 + DF8C16 • 101112 + 101012 Exercise Subtract: • 4678 − 3658 • 32116 − 4556 • 1010112 − 1112 • CAA816 − B9D16 ________________________________________________________________________ Copyright 2007. Number Theory and Cryptology for Middle Level Teachers. Developed by the Math in the Middle Institute Partnership, University of Nebraska, Lincoln. 3