Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
The decimal number system has 10 symbols, octal has 8, binary has 2, hexadecimal 16. One can easily create a number system using any number greater than 1 as its base. For example, Base 17 {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G} base 16 {0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F} base 12 {0,1,2,3,4,5,6,7,8,9,A,B} base 10 {0,1,2,3,4,5,6,7,8,9} base 8 {0,1,2,3,4,5,6,7} base 3 {0,1,2} base 2 {0,1} Why is a number system’s base not a symbol in the number system’s set of symbols? If the base were also a symbol then the representation of a number as the sum of the products of the symbols and powers of the base would become more complicated. A symbol’s value would no longer be a function of its position in the number. Because the base is not a symbol, a symbol’s value is very simple: it is the symbol followed by zeroes. How many zeroes depend on the symbol’s position in the number. The good thing about representing numbers this way is the symbol in one position cannot affect the symbols in the other positions. For example, 378 = 300 + 70 + 8 in some position based number system. Note that replacing the 3 with a 6 does not affect the other symbols. The new number is 678 = 600 + 70 + 8 We perform these expansions by multiplying each symbol by a power of 10 where the value of “10” is ten only in the decimal number system. If we are working with a number system, other than base 10 number system then the value of “10” is this number system is b in the base 10 number system. Suppose, for example, that the value of b is “12”. 37812 = = = = 3 x 102 + 7 x 101 + 8 x 100 in base 12 3 x 122 + 7 x 121 + 8 x 120 in base 10 3 x 144 + 7 x 12 + 8 x 1 in base 10 52410 A related question is why do symbols in different number systems have the same value. For example, why is 310 = 312? They have the same value because it is convenient for us that they have the same value. We could create completely distinct sets of symbols for each number system but then we would have to define how to translate one set of symbols into another set of symbols. We do it when we convert roman numbers into decimal numbers or decimal numbers to roman numbers. But it is extra work. How do we convert from one base to another base? We convert the number from the first base to base 10 and then convert the number from base 10 to the second base 98712 = ?8 98712 = 9 x 12 x 12 + 8 x 12 + 7 x 1 = 9 x 144 + 8 x 12 + 7 x 1 = 1296 + 96 + 7 = 139910 An algorithm for converting from base 10 to base n divides the number repeatedly by the base until the quotient is zero. The converted number is the remainders of the division operation. 1399 = 8 x 174 + 7 174 = 8 x 21 + 6 21 = 8 x 2 + 5 2 = 8 x 0 + 2 98712 = 25678 Why does this algorithm work? 1399 = 8 x 174 + 7 = 8 x (8 x 21 + 6) + 7 = 8 x (8 x (8 x 2 + 5) + 6) + 7 = 8 x 8 x 8 x 2 + 8 x 8 x 5 + 8 x 6 + 7 = 2 x 83 + 5 x 82 + 6 x 81 + 7 x 80 in base 10 = 2 x 103 + 5 x 102 + 6 x 101 + 7 x 100 in base 8 = 25678 convert 183 in base 10 to base 12 183 = 12 x 15 + 3 15 = 12 x 1 + 3 1 = 12 x 0 + 1 18310 = 13312 183 = = = = = = 12 x 15 + 3 12 x (12 x 1 + 3) + 3 12 x 12 x 1 + 12 x 3 + 3 1 x 122 + 3 x 121 + 3 x 120 13312 An algorithm for converting from base n to base 10 expands the number as the sum of products of the symbols and powers of the base and then replaces the base with its value in base 10. e.g. convert 13312 to base 10 13312 = 1 x 102 + 3 x 101 + 3 x 100 = 1 x 122 + 3 x 121 + 3 x 120 = 144 + 36 + 3 = 183 convert 17710 to base 8 177 = 22 x 8 + 1 22 = 2 x 8 + 6 2 = 0 x 8 + 2 17710 = 2618 convert 1778 to base 10 1778 = 1 x 102 + 7 x 101 + 7 x 100 = 1 x 82 + 7 x 81 + 7 x 80 = 1 x 64 + 7 x 8 + 7 x 1 = 64 + 56 + 7 = 12110 Algebra of Exponents Why is a0 = 1 for all a 0? am x an = an+m? a2 x a3 = a x a x a x a x a = a5 That is, a2 x a3 = a2+3 = a5 By convention, a-n = 1/an Moreover, am/an = am-n Suppose m = n then am/an = am-n = a0 = 1 Fractions A fraction is the ratio of two integers where the integer in the fraction’s denominator is not zero. A fraction has a representation has a ratio and as a decimal fraction. Terminating Factions 1/5 = 0.20 Continuous Fractions 1/3 = 0.333... Rules and Conventions 1.000... is not a continuous decimal fraction. Why? 0.999... is not a continuous decimal fraction. Why? How do you convert a fraction from a ratio representation to a decimal fraction representation? How do you convert a fraction from a decimal fraction representation to a ration representation? Why are some fractions continuous decimal fractions? Why are some fractions terminating decimal fractions? How do you know that a fraction has a continuous decimal fraction representation? How do you know that a fraction has a terminating decimal fraction representation? Is it possible that a fraction has a terminating decimal fraction representation in one number system and a continuous decimal fraction representation in another number system? Class Exercises Convert 1002 to base 3 Convert 1002 to base 4 Convert 1002 to base 8 Convert 1002 to base 10 Convert 1002 to base 12 Convert 1003 to base 2 Convert 1004 to base 2 Convert 1008 to base 2 Convert 10012 to base 2 Can we convert 1288 to base 10? Can we convert 2012 to base 10? Does 1/7 have a terminating decimal fraction representation? Does 1/5 have a termination decimal fraction representation? Convert 0.333... from base 10 to base 2 Convert 0.333... from base 10 to base 3 modular arithmetic modular arithmetic always has two operations – addition, and multiplication; always has subtraction but usually ignores subtraction; and sometimes permits division under certain circumstances. Modular arithmetic is useful in number systems with a finite number of numbers. Mod 0 x 0 x 0 x 1 x 1 x 1 x 2 x 2 x 2 x 3 0 1 2 0 1 2 0 1 2 = = = = = = = = = = {0, 1, 2} 0 0 0 0 1 2 0 2 1 Why does 2 x 2 = 1? Modular arithmetic is like ordinary arithmetic with an extra step: we perform the operation, get the result, divide the result by the modulus, in this case “3”, and the remainder is the final result. For example, 2 x 2 = 4, the intermediate result. When we divide 4 by 3 the remainder is 1, our final result. Z3 = {0, 1, 2} 0 + 0 = 0 0 + 1 = 1 0 + 2 = 2 1 + 0 = 1 1 + 1 = 2 1 + 2 = 0 2 + 0 = 2 2 + 1 = 0 2 + 2 = 1 How do we define subtraction? In any number system, for every a in the number system there is a b such that a + b = 0. We then say that a = -b. From the addition table we see that 0 = -0 1 = -2 2 = -1 We also 0 = 0 – 0 = 1 – 0 = 2 – 1 = 1 1 = 2 1 = 0 2 = 2 2 = 0 2 = 1 - define subtraction from the addition table: 0 1 2 0 1 2 0 1 2 An integer’s divisions are those numbers that divide it without remainder. E.g. 12’s divisors are 2, 3, 4, and 6. 8 and 9 are not divisors of 12. A prime number is any positive integer that has exactly 2 distinct divisors - 1 and itself. Is 1 a prime number? Do we get different kinds of results if the modulus is prime or not prime? Some modulus number system can define the operation of division. A modulus number system can divide if a x b = 0 means that a or b = 0. This is not true when the modulus is 4 because 2 x 2 = 0 in the modulus system. It is true whenever the modulus is a prime number. Suppose 1 x 1 = 1 x 2 = 2 x 1 = 2 x 2 = the modulus is 3. 1 2 2 1 We can define division 1 / 1 = 1 2 / 2 = 1 2 / 1 = 2 1 / 2 = 2 Why? If a x b = c then a = c / b Define subtraction and division in modulo 7 Define subtraction and division in modulo 8 What criteria to you use to determine that 11 divides a number? What criteria do you use to determine that 4 divides a number?